css attribute selectors.

style html elements with the specific attributes.

it is possible to style html elements that have specific attributes.

attribute selector.

the example below style all anchor element with href attribute:

<style>
         
         a [href] { color:blue;
         
         text-decoration:underline 
         
         </style>

attribute and value selector

the example below style all anchor element with href=".google.com":

<style>
          
          a [href=".google.com"] { color:blue;
          
          text-decoration:underline 
          
            </style>

styling forms

the attribute selectors are useful for styling forms.

             <style type="text/css" >
             
             input [type="text"]             
             {
              width:150px ;
              
              background-color:pink ;
              
              color:#3a4b9c ;
              
              height:200px ;}
              
             input [type="password"]
             {
              width:150px ;
              
              background-color:#3a4b9c ;
              
              color:lime ;
              
              height:200px ;}
              
             input [type="button"]
             {
                width:150px ;
                
                background-color:#3a4b9c ;
                
                color:white ;
                
                height:200px;
                
                border:1px dotted pink ;  }