IE Bug – making a 0px high div
I found that when I was creating div’s with ‘clear:both’ of different heights (which I use for spacing in my design)
.clear {clear: both; height: 0px; line-height: 0px; width:100%;}
.clear5 {clear: both; height: 5px; line-height: 5px; width:100%;}
.clear10 {clear: both; height: 10px; line-height: 10px; width:100%;}
.clear20 {clear: both; height: 20px; line-height: 20px; width:100%;}
Basically spanky IE makes your empty div the same height as your line height – so to fix this you need to specify line height ‘0px’ etc etc.
Bad bad IE
Correct accessible image / text replacement
Stolen from : csswizardry
7.3.2 Gilder/Levin Method
Really great method…
By far the most robust and accessible method to date is the Gilder/Levin method (no URL available). This method maintains its integrity with all combinations of images on/off and CSS on/off.
This method works by laying an empty <span> over the top of the parent element with the required image applied as a background to that <span>:
Markup:
<h1><a href="./" title="Return Home"><span></span>Home</a></h1>
CSS:
#header h1 a{
display:block; /* Required */
width:250px; /* Width of image in question */
height:70px; /* Height of image in question */
position:relative; /* Required */
}
#header h1 a span{
position:absolute; /* Required */
width:100%; /* Stretch full width of parent */
height:100%; /* Stretch full height of parent */
background:url(images/logo.gif) top left no-repeat; /* Image */
cursor:pointer; /* Required for links to appear like links in IE */
}
…but has its drawbacks:
There is however a drawback to this method; the empty <span>. This is bearable though as the <span> will have no impact on the usability/accessibility on the page, and will only impact ever so slightly on semantics. Now users can always see an image or text regardless of whether they have CSS and/or images disabled.
Weird first list item indent IE 6/7 – fix!
For some reason – IE 6/7 has a bug *sometimes* of making the first item of a list indented *RANDOM*
so your list looks like this:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
Which will end up looking something like this (yes I just dummied it to look like this – it’s not the actual error):
- Item 1
- Item 2
- Item 3
To fix it:
ul{
min-height: 1%;
}
ta da!
Center align site using CSS
HTML bit
<body>
<div id="wrapper">
**Rest of site goes here**
</div>
</body>
CSS bit
body {
text-align: center;
}
#container {
margin: 0 auto;
width: ***px;
}