Sunday, 12 August 2012

css border property tutorial


Introduction of Css Border property


css background property is used to set border around html tag. Css border works with cordination of three sub properties.
  1. border-style : This property sets style of border. We can choose some predefined styles.Which are
    • solid
    • double
    • groove
    • dotted
    • dashed
    • inset
    • outset
    • ridge
    • hidden
        Syntex :
        selector
        {
          border-style :solid;
        }
        
  2. border-width : This property sets width of border. Values are in px,thick,medium.
        Syntex :
        selector
        {
          border-width :7px;
        }
     
  3. border-color : This property sets color of border.
        Syntex :
        selector
        {
          border-color :red;
        }
     
  4. Example
        Syntex :
        selector
        {
           border-width:2px;
           border-style:solid;
           border-color:red;
        }
        
    Click to practice online example

We can also implement seperate border for each(left,top,right,bottom).

  • border-left :
        Syntex :
        selector
        {
           border-left-width:2px;
           border-left-style:solid;
           border-left-color:red;
        }
        
  • border-top :
        Syntex :
        selector
        {
           border-top-width:2px;
           border-top-style:solid;
           border-top-color:red;
        }
        
  • border-right :
        Syntex :
        selector
        {
           border-right-width:2px;
           border-right-style:solid;
           border-right-color:red;
        }
        
  • border-bottom :
        Syntex :
        selector
        {
           border-bottom-width:2px;
           border-bottom-style:solid;
           border-bottom-color:red;
        }
        
We can also apply border in single line. In this way first we need to set border width then border style and in last border color.
    Syntex :
    selector
    {
       border:1px solid red;
    }
    
Click to practice online example

No comments:

Post a Comment