Grow your CSS skills. Land your dream job.

color

Last updated on:

The color property in CSS is specifically for controlling the color of text.

p {
  color: green;
}

I'm an example of the above CSS taking effect on a specific paragraph.

You can use any color value, for instance:

#f00
#ff0000
rgb(100,100,100)
rgba(100,100,100,0.5)
hsl(20, 100%, 50%)
hsla(20, 100%, 50%, 0.5)
named colors

The color property does cascade. So for instance if you set it on the body, all decedent elements that don't have their own color set in the user agent stylesheet will inherit that color.

Browser Support

Chrome Safari Firefox Opera IE Android iOS
any any any any any any any

Leave a Comment

Posting Code

Markdown is supported in the comment area, so you can write inline code in backticks like `this` or multiline blocks of code in in triple backtick fences like ```this```. You don't need to escape code in backticks, Markdown does that for you.

Sadly, it's kind of broken. WordPress only accepts a subset of HTML in comments, which makes sense, because certainly some HTML can't be allowed, like <script> tags. But this stripping happens before the comment is processed by Markdown (via Jetpack). It seems to me that would be reversed, because after Markdown processes code in backticks, it's escaped, thus safe. If you think you can fix this issue, get in touch!

If you need to make sure the code (typically HTML) you post absolutely posts correctly, escape it and put it within <pre><code> tags.

Current ye@r *

*May or may not contain any actual "CSS" or "Tricks".