1. Three ways to use CSS style sheets in HTML:
(1) Inline style sheets.
eg:LIN
(2) Embedded style sheet.
That is, embed the
When these properties conflict with css rules, Always overridden by css rules.
4. Use in rules! important
Use! The rule specified by important is more important than other rules.
eg: em { color: bule! important;}
Attention: User first! important rules take precedence over the author's rules.
User-defined style sheets should be declared! important.
5. @import rules, import files.
eg: h1 {color: red;}
@import url("style.css");
/*style.css*/
h1{color: green;}
The above code, the final h1 is red. Because by default the imported stylesheet appears before the original stylesheet rules.
(1) Note that display, border, margin, padding attributes are not inherited.
(2) background-color is not inherited. When it is not set, its default value is the special value transparent.
(3) When inheriting a relative value, the value is first calculated before passing it to the descendants.
(4) Specify inheritance: inherit special value
eg: p .standout{ border: 1px solid blue;}
p .standout{ border:inhert;}
Note: When css 1 was released, the author's! important style takes precedence over the user's! important style.
css2, user's! important style takes precedence over the author's! important style.
The above is the detailed content of Learn more about the use of CSS cascades and inheritance. For more information, please follow other related articles on the PHP Chinese website!