Let me start by saying that this method uses a new feature found in the CSS 3 spec. So, it might not be the best idea for desktop site use, but it comes in quite handy in mobile development.

I've had a good number of designs that require part, or all of the layout to have the link color match the text color.

Before the advent of CSS 3, this was a manual process of assigning a color style to each place in the document that an anchor tag might appear.

I introduce to you the currentColor variable. Unlike user-defined CSS 3 variables, this "built-in" variable is well supported by all the major browsers.

To force all links to carry the same color of their parent, simple tack this rule at the top of your CSS:

a { color: currentColor; }

That's it!

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *