This article is a summary of Chapter 10th of HTML & cssdesign and build websites.
A css rule consists of two parts:Selector {declaration}A declaration is a combination of property: value. Multiple selectors can have the same declaration, separated by commas.
H1, H2, H3 {font-family: Arial; color: yellow ;}
After CSS is written, how can we make it show results?
There are two types: external, internal, CSS, and link, the other is that CSS code is directly embedded in HTML,
External: It must be placed under the head node. This is understandable. After all, you must know these styles before introducing the body,
<link href="css/styles.css" type="text/css" rel="stylesheet" />
Internal:
<style type="text/css"> body { font-family: arial; background-color: rgb(185,179,175);} h1 { color: rgb(255,255,255);} </style>
Selector can have many types:
A) Global * {} indicates that all elements on the current page are effective.
B) element name, such as H1, H2, H3 {}
C) Class, the class of the element. There must be a number here ,. note {} or P. note {}, the difference between the two is that the previous one is useful for all the nodes where the class is the note, note is only useful for the class under the node whose name is P.
D) ID, the element ID. It starts with the # symbol. It is similar to jquery. # Introduction {}
E) There is also a location-related selector,
Child: LI> {}
Descendant:
P {}
Adjacent sibing:
H1 + P {}
General sibing:
H1 ~ P {}
If there are so many selector conflicts, it is generally more specific to replace more general global rules. Another way is! Important
p b {color: blue !important;}
There are also many types of properties, which will be introduced in the next article.