Summary of various cascading style instances in CSS

Source: Internet
Author: User
CSS (cascading style sheets) is used to specify the rendering of HTML documents. Everything has a sequence, all things have a seniority. Under normal circumstances, there is no difference, that is, the so-called equality of sentient beings. However, when conflicts occur, it is clear that it is impossible to do exactly the same, sequencing, identity differences appear. Cascading is the process by which a browser overlays multiple style sources and ultimately determines the results. This article is to talk about the specific role of CSS cascading styles.

First, you can learn the free course of PHP Chinese network.

1. Learn the CSS Cascade Tutorial in Html+css of the blink of an association

CSS cascading styles

1. CSS style inheritance and cascading

Features: The tag Selector selects all of the specified tags in the current year's page, and the tag Selector has no association with the tag hierarchy of the code, as long as it is selected on the current page.

ID Selection: You need to specify a label setting ID value (the ID value cannot be repeated only on the entire page). Class Selection: Select the specified label through the class selector by giving the tag a class name.

2. Detailed CSS cascade mechanism

Cascading in cascading style sheets means that styles are passed from one level in the document structure to another, and that the browser determines which source's style attributes are applied to a tag in many sources.

Cascading is a powerful mechanism. Understanding cascading helps you to write CSS in the most economical and maintainable way, and also helps you create the most desirable appearance of your document based on your wishes.

3. Detailed CSS inheritance features and cascading features

The first p does not use a selector, so the HTML default display color (black)

The second p uses the class selector, so the color of the class selector takes precedence (red)

The third p uses the ID and class two selectors, because the ID selector has a higher precedence than the class selector, so the color is displayed in blue

The fourth p uses the inline selector and the ID selector, because the in-line selector takes precedence over the ID selector, so the color is displayed in yellow

The fifth P uses two class selectors at the same time, and the browser interprets the page with the color of the first class selector as defined, so the color is displayed in purple

The sixth P uses two ID selectors at the same time, but since the ID selector can only be used for a single tag and globally unique, the browser considers this to be an illegal color with its default value (black)

4. Detailed description CSS Cascading style sheet

[attribute] selects the element with the attribute attribute.

[Attribute=value] Selects an element with a attribute attribute and a property value equal to value.

[Attribute~=value] Selects a list of words with a attribute attribute and a space-delimited property value, where one element equals value.

[Attribute|=value] Select the e element with the ATT attribute and the attribute value to begin with Val and the string delimited by the connector "-".

[Attibute^=value] matches the e element with the attribute attribute and the value begins with Valule

[Attribute$=value] matches the e element with the attribute attribute and the value ends with

[Attribute*=value] matches the e element with the attribute attribute with value

5. Analyzing values for CSS style sheets, inheritance, cascading, and properties

CSS has properties that control the basic formatting (such as font-size and color, etc.), have properties that control the layout (such as position and float, etc.), and print control elements that determine where the visitor prints when the page is changed. There are many other attributes as well.
The style sheet contains rules that define the appearance of the Web page, with each rule having two main parts: selector (selection) and declaration block (declaration). The selector determines which elements are affected, and the declaration block has one or more attribute-value pairs that make up what should be done.

6. CSS particularity, inheritance and Cascade

A declaration marked!important is called an important declaration, which is not specific, but is considered separately from non-important statements.

In particular: non-important declarations are grouped into one group, and conflicts between them are resolved using specificity; Important statements are grouped into a set of conflicts within them, and important statements always take precedence over non-important statements.

Related questions

1. How can an element with no cascading context be larger than the element Z-index?

2. iOS webview loading HTML file, no problem at 9.2, but horizontal layout cascade at bottom of 8.1

"Recommended"

1. PHP Chinese Web free video tutorial: "Php.cn lonely Nine Cheap (2)-css video Tutorial"

2. PHP Chinese related article: css Let Div overlay instances summarize

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.