1.CSS (cascading style sheets)
2.CSS syntax
selector {
Property name 1: attribute value 1;
Property Name 2: attribute value 2;
}
3. Three-way reference to CSS
First type: inline style
Example: <a style= "color:red;" > Internal Styles </a>
Second type: internal style
In the Head tab, write the style label.
Cases:
......
<style type= "Text/css" >
h1{
......
}
</style>
Third type: external style
Steps to use:
A) Create a file (CSS file) with a suffix of. css
b) Introduction of CSS files via link in HTML
<link rel= "stylesheet" href= "CSS file path"/>
4. Basic Selector
4.1 Tag Selector
Label name {}
Class 4.2 Selector
The. Class Property value {}
4.3 ID Selector
#id属性值 {}
5. Hierarchy Selector
5.1 descendant Selector
Parent element child element {}
5.2 Sub-selectors
Parent element > child element {}
5.3 Neighboring brother Selector
This element + adjacent sibling element {}
5.4 General Brotherhood Selector
This element ~ Sibling element {}
6. Structure pseudo-Class selector
E f:first-child{}//First child element
E f:last-child{}//Last child element
E f:nth-child (?) {}//? Represents the first few child elements, can also make odd odd, even even
E f:first-of-type{}//The first element of a specified type
E f:last-of-type{}//The last element of the specified type
E f:nth-of-type (?) {}//? Indicates the number of child elements of the specified type
Attention:
E F:nth-child (n) is found in the parent from an element, without typing.
E F:nth-of-type (n) Look at the type first in the parent, and then look at the position.
7. Property Selector
E[ATTR]//element with attribute attr
E[attr=val]//The value of the Attr property is the element of Val
E[attr^=val]//attribute attr The value of the element starting with Val
E[attr$=val]//attribute attr The value of the element ending in Val
E[attr*=val]//attribute attr The value of the element containing Val
The fourth chapter-First knowledge of CSS