1. Basic syntax
Selector1, selector2{
property1:value1;
Property2:value2;
}
If value is greater than 1 words (such as font-family may be sans serif), quotation marks (font-family: "sans serif") are required
2. Advanced syntax
Inheritance effect
3. Deriving selectors
Define a style based on the context of the element location
<! DOCTYPE html> en > <meta charset=" utf-8 > <title></title> <link rel= " stylesheet " Type= " text/css " Href= " mycss.css " >
// derived selection labels are separated from outer to inside with spaces p strong{ color:aqua;}
4. ID Selector
Specify a style for the element labeled ID, in # to define
<! DOCTYPE html> en > <meta charset=" utf-8 > <title></title> <link rel= " stylesheet " Type= " text/css " Href= " mycss.css " > " > <strong> derivation selection </strong> </p></body>
// The ID selector is represented by the #, and the context location is the derived selector, both with #pid strong{ Color:aqua;}
4. Class Selector
Use. To express
<! DOCTYPE Html>"en"> <meta charset="UTF-8"> <title></title> <link rel="stylesheet"Type="Text/css"href="Mycss.css">class="Pclass"> <strong> derivative selection </strong> </p></body>// class selection and derivation selection in conjunction with . Pclass strong{ Color:aqua;}
5. Property Selector
2.2 CSS3 Basic syntax + selector