Jump to content

breaking inheritance


jcombs_31

Recommended Posts

I guess this has never become a huge issue with me, but something I can't seem to get around.

 

If I set an element such as a paragraph

 

p {
  padding: 0;
}

 

and later decide I need a class to have some padding on the left

 

.padded {
  padding: 0 0 0 20px;
}

 

and then in my markup

 

<p class="padded">This padding is ignored based on my first padding</p>

 

How do I get around this?

Link to comment
https://forums.phpfreaks.com/topic/112215-breaking-inheritance/
Share on other sites

@jcombs download firebug (why is the FireFox3 release not finished!!!!) and you can see which rules are being applied to your markup very easily.

 

It is actuall better to just have #container .padded in fact its better to have the minimum amount of code possible whether it be css, xhtml or php!!!

 

reducing mass makes your projects much more maintainable..

Link to comment
https://forums.phpfreaks.com/topic/112215-breaking-inheritance/#findComment-576327
Share on other sites

if .padded and/or p.padded isn't taking precedence over p, then you have a different CSS declaration that has the padding set to zero that is overpowering them. Both of the declarations are stronger than p alone.

 

Using firebug will show you which declaration is the strongest, and you can see where t hat declaration is coming from.

Link to comment
https://forums.phpfreaks.com/topic/112215-breaking-inheritance/#findComment-576508
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.