Welton122 Welton122 - 1 month ago 20
CSS Question

CSS * overriding class style

I'm having some difficulty with applying CSS. I have a text color specified in a global external style sheet, which uses * to apply the color. I'm now trying to override this for one specific class. I've tried setting the text color for the class within the header of the document (which if I'm correct should override the external sheet?), however the color will not change.

Google chrome inspector shows me that * is still dominating the class specification. Any ideas?

My external style sheet looks like this:

* {
font-size: 14px;
color: #666;
}


and my header style looks like this:

.error-list {
color: red !important;
}


Its worth mentioning that I've tried it with and without the !important.

Answer

Try making your CSS rule more specific. For example if your .error-list is made of li tags. Change your CSS rule to .error-list li to make it more specific.

Comments