Forum Moderators: not2easy

Message Too Old, No Replies

List Element not affected by padding or margin changes?

Discussion about adding padding or margin to a list element

         

rezachemical

9:19 pm on Jun 16, 2006 (gmt 0)

10+ Year Member



is there a reason why when i put a padding or margin declaration on a list item by using it's class name why it doesnt work?

as in: list has a class name of let's say "list" and i go:


.list {padding:0px; margin:0px;}

4css

9:45 am on Jun 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you go to list a matic's site, there are tons of tutorials for you to work through for styling lists. It is a site I highly suggest for lists.

Setek

1:57 am on Jun 19, 2006 (gmt 0)

10+ Year Member



As a more specific answer, it's possible your specificity is incorrect :)

For example, you may be using

.list
to remove
margin
and
padding
, but
div#menu ul li { margin: 10px; padding: 10px; }
is in the way :)

4css

11:10 am on Jun 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



another good way to removed your paddings, margins and borders is to go with a global style in the begining of your style sheets, then add when and where needed
*{
margin: 0px;
padding: 0px;
border: 0px;
}
This removes all defaults that browsers may have and then you can add what you need as you need it.

zackattack

11:46 am on Jun 19, 2006 (gmt 0)

10+ Year Member



Hi rezachemical

can you put the (X)HTML code up..? this always helps

any of these are a possibility:

1) You applied the style incorrectly
2) You only have the class applied to the ul element and not the li as well (or visa versa) and the default padding or margin is being applied
3) Something higher up the heirachy chain is already controlling the padding and margin and your class is not over ruling this (this is the specificity issue that Setek mentions in his post above - because of the Cascade there is an order of control that each element,div and class has over each other. As it stands with the way that it looks like you have set this class up it is pretty much at the bottom of the cascade, therefore something higher up the order could be controlling the margin and padding

do you have any other styles applied to ul or li elements anywhere else in your CSS..?

show us the (X)HTML so we can see how the class has been applied

ZA