Steve
Steve

Reputation: 1

child theme css class issue

I'm a student. I'm building a WordPress child theme on my blog. I @import the parent theme. I define a class as the last statement of the child theme. Part of the class is working as I use the class on a header tag to make the text red. The margins I define in the class are being overridden by the parent theme? Why? http://rollingokie.com/how-to-find-cheap-airfare/ -> inspect element -> "Understand" Oh, and yes, I read the Coyier article and !important works. So what's happening in the cascade I don't understand? Are the specificity values for my margins identical to the values in the parent theme? Thanks. You people are great. Mostly...

Upvotes: 0

Views: 54

Answers (1)

kelly johnson
kelly johnson

Reputation: 1636

Well, you need to look into specificity. That doesn't mean chaining a bunch of classes, it means that elements themselves, like the h2 tag itself have a 'weight' as do classes and ID's.

ID's override classes no matter how many you have so:

<div class ="firstDiv firstP redHeader">stuff</div>

is not as "specific" as:

<div id="colorMeRed">stuff</div>

No matter where or when the rules come in (not counting inline styles of course) that one ID has greater weight than those three classes and will override.

So google 'specificity and weight'. You'll find this: 0100 = one id, where my example above with classes would be =0030. Notice the placement. 01 is greater than 003

Upvotes: 1

Related Questions