CSS's Color property is not available for text display only

Source: Internet
Author: User

Although CSS is not a very complex technology, but even if you are a use of CSS for many years, there will still be a lot of CSS usage/attribute/attribute values you have never used, even never heard of.

For CSS color Properties, it is believed that all Web developers have used it. If you are not a particularly experienced programmer, I believe you may not know that attributes can be used color in addition to text display, but also as other places.

You can start by looking at the following demo:

HTML code
<img alt="Example alt text" width=" height="  $ "><ul>  <li>example list item</li></ul><ol>  <li> Example List item</li></ol>
CSS Code
body {  color:yellow;  Background: #444;  Font-size:20px;  Font-family:arial, sans-serif;  Text-align:center;} UL {  border:solid 2px;  Text-align:left;} OL {  text-align:left;} HR {  Border-Color:inherit;}

Please note that only one attribute is used in the above code, which color is body set to the element yellow . But, as you can see, all the stuff on this page turns yellow, including:

    • Cannot display the text of a picture alt
    • The border of the list element
    • The dot in front of the unordered list element
    • Number preceding the ordered list element
    • and an hr element.

Interestingly, this hr element, by default, does not inherit from the body color property, but I use border-color: inherit force to inherit it. This is a very strange feature.

This is said in the CSS specification:

This property declares the foreground color (foreground color) of the element text content. In addition, its value is also used for indirect references elsewhere .... For example, other properties that can accept color values.

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.