Test instance learning, about writing CSS sequence research

Source: Internet
Author: User
Tags definition
Css

The last defined CSS style overrides all existing or conflicting styles defined before it, such as the following example:

p {color:red; Background:yellow}
p {Color:green}

The above paragraph will eventually render a green font, with a yellow background, this is because the last defined Color:green is covered by the previously defined red, and the reason why the yellow background does not disappear is because the definition of the second P has no definition of the conflict, so it is still valid.

Do you really understand? Okay, let's do a little test:

p.red {color:red}
P.green {Color:green}
P.blue {Color:blue}

...

<p class= "Red Green Blue" >sample text.</p>
<p class= "Green Blue Red" >sample text.</p>
<p class= "Blue Red Green" >sample text.</p>

What color will the text appear in the three paragraphs above when it is finally displayed?

Think about ^_^.

The answer is that they all appear to be blue, that is, blue, although each paragraph has three P styles applied in different order, it should appear that the color should be determined in the order in which the style is applied, for example, the first one is blue, the second is red, and the third is green, which is actually wrong, This has nothing to do with the order in which styles are applied, and they all end up with the last-specified style, blue in color.



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.