CSS3’s Color Property

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:

Join us in our newest publication:
  • 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:

  1. /* name value */
  2. p{
  3. color: white;
  4. }
  5.  
  6. /* hex value */
  7. p{
  8. color: #ffffff;
  9. }
  10.  
  11. /* rgb value */
  12. p{
  13. color: rgb(255, 255, 255)
  14. }
  15.  
  16. /* rgba value */
  17. p{
  18. color: rgba(255, 255, 255, 0)
  19. }

Share and Enjoy !

0Shares
0 0