View Full Version : How to break out of a div id p

02-12-2011, 03:23 AM
I have part of a webpage structured like this:

div id -->1
div id p -->1

div id --> 2
div id p --> 2

div class --> 3
div class p --> 3

div class --> 4
div class p --> 4


The problem is that I'm trying to change the styling of div class p 4 but no matter what I try it's retaining the styling of div class p 1. I'm newer to understanding div classes so I don't understand why it's stuck as a child to that div and won't change?

Any idea's? I'd post a link but can't so hopefully my diagram is good enough. It's a pretty strait up question that I've come across before so hopefully that's ok. Feel free to ask questions or give advise.

02-12-2011, 01:20 PM
I sounds like you have a CSS specificity problem.

02-12-2011, 06:18 PM
Man, I can't tell you how much I appreciate that link. I spent a good 4 hours yesterday trying to figure it out and tossed and turned all night thinking about it frustrated. Had a bad day yesterday on top of it. I was sure I wouldn't get help without a link and woke up ready to have another crap morning fighting this thing.

Finally I understand how this stuff is calculated. And that article broke it down into such easy terms. I've always stuck with css 101 and did strait #divs, #p's, .classes, and inlines. Now I've ventured off into the longer selectors etc and it worked like a charm!

I already had it all setup as a million inlines but wanted to rewrite it for a proper separate stylesheet. It just wasn't happening...

Anyways, thanks for making my saturday something I can enjoy now!

02-12-2011, 06:43 PM
You're welcome, man! I've read quite some articles about this subject (which is a tough one), but this article was the one that made me fully understand how the math goes. :)