CSS3’s Color Property

Published June 20, 2016 by saurav.roy.

I think it’s safe to say that almost every beginner developer knows that CSS’s color property is used to define the color of your HTML text elements. What many beginner developers might not know, however, is that the color property can also be used to define the color of other HTML elements as well.

In addition to text, the color property applies to:

  • Bullets or other list-style markers on an unordered list
  • Numbers on an ordered list
  • Borders applied to list items
  • The <hr> element
  • Alt text displayed when an image doesn’t load

It’s also worth noting that the color property takes several different types of color values. There’s the color name value, the hex code value, and the rgb or rgba value. See examples of each below:

/* name value */
color: white;

/* hex value */
color: #ffffff;

/* rgb value */
color: rgb(255, 255, 255)

/* rgba value */
color: rgba(255, 255, 255, 0)

Share and Enjoy !

0 0