Saturday, 8 April 2017

css selector

The Class Selectors
You can define style rules based on the class attribute of the elements.
.black{color:#000000;}
h1.black{color:#000000;}
 The ID Selectors
#black {color:#000000;}
 h1#black{color:#000000;}
#black h1{color:#000000;}
The Child Selectors
body >p{color:#000000;}
This rule will render all the paragraphs in black if they are a direct child of the <body> element. Other paragraphs put inside other elements like <div> or <td> would not have any effect of this rule
 The Attribute Selectors
input[type="text"]{color:#000000;}
 Multiple Style Rules
You may need to define multiple style rules for a single element.
h1
{
color:#36C;
font-weight:normal;
letter-spacing:.4em;
margin-bottom:1em;
text-transform:lowercase;
}
 Grouping Selectors
 h1,h2,h3
{
color:#36C;
font-weight:normal;
letter-spacing:.4em;
margin-bottom:1em;
text-transform:lowercase;
}
You can combine the various class and id  selectors together as shown
#a,#b,.c
{
color:#36C;
font-weight:normal;
letter-spacing:.4em;
margin-bottom:1em;
text-transform:lowercase;
}

No comments:

Post a Comment

Please write your view and suggestion....