Johan Brook

  • About
  • Heroes
  • Archive
  • Projects
  • Log
  • Contact

What's this?

I'm Johan, and I'm interested in interface design and front-end development. I freelance as web designer and developer, and study Software Engineering in Gothenburg, Sweden.
More about me

  • Twitter

    @johanbrook
  • Subscribe with RSS

    johanbrook.com/feed
  • E-mail me

    johan at johanbrook . com
More contact stuff
Linked http://nimbupani.com/current-color-in-css.html

Use the current color in CSS with the currentcolor keyword →

‹ Previous post · Next post ›

January 28, 2011 · Permalink · Read more posts about Design and CSS

Say you have a paragraph with the CSS of color: red;. If you would want to add a border in the same color you would just have to type border: 1px solid;. The border-color inherits from the paragraphs color property.

How about using your element’s color value for other things than border-colors? A neat CSS keyword I didn’t know about makes this possible: currentcolor. Treat it as any other color keyword (like red, blue, green etc.) and wherever it’s used, the color of the color is used.

p {
   color: red;
}

p span{
   background: currentcolor;
}

Firefox, Safari, Chrome and Opera supports the keyword but alas, not IE9 yet.


Johan Brook 2007-2013 · Godkänd för F-skatt