I am facing an issue with some CSS. Below is my HTML code:
<body>
<div id="cn">
<div id="hd">
<ul>
<some li's>
</ul>
</div><!-- /#hd -->
<div id="bd">
</div><!-- /#bd -->
<div id="ft">
</div><!-- /#ft -->
</div><!-- /#cn -->
Here is the associated CSS:
div#cn {
position: relative;
width: 960px;
margin: 0 auto;
background: #f7f7f7;
}
div#cn > * {
position: relative;
}
div#cn div#hd {
height: 258px;
background: #f7f7f7 url(../img/hd.jpg);
}
div#cn div#hd ul {
margin: 50px 0 0 0;
padding: 0;
list-style-type: none;
}
div#cn div#hd ul li {
float: left;
}
div#cn div#hd ul li a {
display: block;
height: 35px;
padding: 20px 25px 0 25px;
font-weight: bold;
background: pink url(../img/nava.jpg) right 0 no-repeat;
}
Currently, the margin is not affecting the UL but the Div around it (#hd) in Firefox. It appears as if the margin is applied on #hd instead of the ul. Interestingly, setting a border to #hd seems to make it work! (Alternatively, placing a non-breaking space before the UL also works)
Can anyone explain why this behavior is happening and provide a proper solution to fix it without resorting to setting a border?