Learn more about the use of CSS cascades and inheritance

高洛峰
Release: 2017-03-17 10:37:07
Original
1331 people have browsed it

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.

6.Inheritance

(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!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!