Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of CSS Advanced Grammar

Shulou Source: shulou.com Published: 2022-06-01 06:56:15 10月03日 Update

This article mainly introduces the example analysis of CSS advanced grammar, which is very detailed and has certain reference value. Friends who are interested must finish it!

Grouping of selectors

You can group selectors so that grouped selectors can share the same declaration.

Separate the selectors that need to be grouped with commas. In the following example, we group all the title elements. All the title elements are green.

H2,h3,h3,h4,h6,h7 {

Color: green

}

Inheritance and its problems

According to CSS, the child element inherits attributes from the parent element. But it doesn't always work this way. Look at the following rule:

Body {

Font-family: Verdana, sans-serif

}

According to the above rule, the body element of the site will use the Verdana font (if the font exists on the visitor's system).

Through CSS inheritance, child elements inherit attributes owned by the highest-level elements (in this case, body) (such as p, td, ul, ol, ul, li, dl, dt, and dd).

No additional rules are required, all child elements of body should display Verdana fonts, and so should child elements of child elements. And in most modern browsers, this is true.

But this may not happen in the bloody era of browser wars, when support for standards was not a priority for companies. Netscape 4, for example, does not support inheritance, ignoring not only inheritance but also the rules that apply to body elements. There is still a problem with IE/Windows until IE6, and font styles in the table are ignored. What should we do?

The above is all the content of the article "sample Analysis of CSS Advanced Grammar". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Elements grouping selection fonts rules advanced examples syntax analysis content attributes titles browsers articles questions support browsing highest same value Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Information MariaDB OPPO Reno Docker