Firefox vs IE

Using IE is like fucking someone with a used condom that's been used many times by many people.
 
I don't get it. What's wrong with IE? Everybody always slates it. Works fine for me.
 
I don't get it. What's wrong with IE? Everybody always slates it. Works fine for me.

http://www.bonrouge.com/~faq#ieiscrap

At the moment, most people struggle with IE6. IE7 arrived recently with many of IE6's bugs fixed (Yaay!). However, there are still some problems with that one too. Microsoft is currently trying to push IE7 onto Windows XP users (not supporting earlier versions of Windows), but I think, unfortunately, many users won't get that for quite a while as it requires users to validate their Windows installation. Believe it or not, some copies of Windows are pirated and users with pirate copies won't see the benefits. Anyway, I think it's fair to say that IE6 is a bit crap... and here are a few reasons why:

*
IE6 treats 'height' as other browsers treat 'min-height'.

The 'height' property is supposed to fix the height of an element - if there's too much text for the element, you should use the 'overflow' property to allow the user to scroll to see the rest of the content. IE doesn't do this though - if there's too much text, IE just makes the div bigger! Moron.
*
IE6 only applies pseudo-classes like ':hover' to the 'a' tag.

This is bloody typical. The :hover pseudo-class is particularly useful for things like CSS dropdown menus and highlighting (data) table rows, but IE only recognises it when it's on the 'a' tag. Stupid boy. For example, the Suckerfish menu on this site works fine in Firefox, but IE needs some ********** to get it to work properly. It's not always good to build menus with ********** though, as some people have it disabled.

Other things IE6 doesn't recognise include ':after', ':before' and ':target'...
*
IE6 treats floats differently to other browsers

It clears floated elements, which sometimes seems like a positive thing as it causes fewer problems for developers, but if it's doing things wrongly, it can't be good...

(With other browsers, developers have the kind of problem talked about on my Clearing floats page).
*
The 3px jog

IE6 adds 3px of padding to the right-hand side of a left floated element when there is a static or relative-positioned element next to it. You keep messing around with it - setting margins to zero, trying to move things around a little and all sorts, but you can't fix it - there's a 3px gap between the left floated element and the element to its right. 'Bloody Microsoft!' you think...

Let's say your left-hand float is 200px wide and the next element has 'margin-left:200px;', which puts it in the right position in good browsers but 3px further right in IE. Well, here's how to fix it. (This wasn't my idea by the way, I copied it from Paul's CSS FAQ at Sitepoint). Put this in an IE-only style sheet and link to it with IE conditional comments.
CSS
#left {
margin-right:-3px;
}
#right {
height:1px;
margin-left:197px;
}
*
Quirks mode

Developers sometimes don't insert a proper DTD at the top of their page or put something else - like an XML declaration - before the DTD. This causes IE to go into quirks mode, which is, well... quirky.

This uses what they call the 'broken box model'. Basically, the standards say that the actual width of a block-level element is width + padding + border. The broken box model says that the actual width is whatever you put for 'width' in your CSS - the borders and padding go inside that.

This difference can cause all sorts of problems.
*
'hasLayout'

The 'wise' people at Microsoft included a property called 'hasLayout' in IE and this is the cause of many rendering problems, such as disappearing text/backgrounds and elements appearing in seemingly inexplicable positions. There are certain properties and values that will return 'hasLayout' as true (see the link), and one of those is 'display:inline-block'. You can often fix hasLayout problems by using this.
CSS
#element{
display:inline-block;
}

Of course, this may cause other problems, but it often usually doesn't. If you do have problems with that method, you can target IE with IE conditional comments, something like this:
<!--[if IE]>
<link href="ieonly.css" rel="stylesheet" type="text/css">
<![endif]-->

This will feed an IE-only style sheet to IE. If you need to force hasLayout on an element, you can put the rule in there. One rule that forces hasLayout is 'zoom:1;'. It doesn't do much else, so you could use that. It's not valid code, meaning that it wouldn't pass the W3C validation, but the validator doesn't read anything in IE conditional comments and, let's face it, you're using it as a hack so does it really matter?

(A great article all about 'hasLayout')
*
IE6 doubles margins on floats

If you have an element that is floated left and you give that element a left margin, IE6 decides to double that margin. That can be fixed by adding 'display:inline' to the rules. Why that fixes it, God only knows - but it does.
*
You can't make a div that's smaller than the font-size in IE6

There isn't usually much need to do this, but I've seen lots of people trying to make very small divs so that they can have some kind of divider (I'd recommend using a border or a background-image in another element).

If you make a div with 3px height, IE6 will give you a div which is about 20px tall - the height of your font. To fix this, you just need 'font-size:0;'.
*
IE6 doesn't support...
o position:fixed

If you're smart, then you're viewing this site in a good browser and you'll see my menu on the left as I intended it to be - fixed on the left-hand-side of your screen. If you're using IE6, you probably can't see my menu because it's scrolled up out of view - because IE is crap.
o min-width/max-width or min-height/max-height

This is discussed below.
o :target

There's a nifty way of doing what I do on my Switching content page without **********. It uses ':target' and of course doesn't work in IE6.

Here's an example:

These paragraphs are all set to 'display:none' in the css, and the ':target' style says 'display:block'.

Here's the CSS : CSS
#t-text p{
display:none;
}
#t-text :target {
display:block;
}

It doesn't get much simpler than that does it?
+ One
+ Two
+ Three

The only problem with this - apart from the fact that it doesn't work in the most widely-used browser - is that it kind of needs to be near the top of a page to get the desired effect. As you can see here (well, I hope you can see what's going on) the hidden element appears when the navigation link is clicked, but it also puts that element at the top of the viewport, which we might not want. The effect should work well if your page is small (example).
o :before or :after or content

"This is new!" (:before) and "This is new too!" (:after).
HTML
<p><span class="new-b">"This is new!"</span> (:before) and <span class="new-a">"This is new too!"</span> (:after).</p>
CSS
.new-b:before, .new-a:after {
content:url(new.gif);
}
o :first-child

This paragraph is a first child and should look different from the second paragraph.

This is the second paragraph.
CSS
#first-child-ex p:first-child {
font-style:italic;
color:#CC0000;
}
o <q>quotes tags</q>

'q' tags give us quotation marks in Firefox, but not in IE.

"Of course the people don't want war. But after all, it's the leaders of the country who determine the policy, and it's always a simple matter to drag the people along whether it's a democracy, a fascist dictatorship, or a parliament, or a communist dictatorship. Voice or no voice, the people can always be brought to the bidding of the leaders. That is easy. All you have to do is tell them they are being attacked, and denounce the pacifists for lack of patriotism, and exposing the country to greater danger." -- Herman Goering at the Nuremberg trials
o attribute selectors

These define styles by an element's value, for example, I have style rules for 'a' tags in my stylesheet, but this extra rule for links to Google will overrule those rules.
CSS
a[href="http://google.com"] {
color: #CC0000;
font-size:1.1em;
border:1px dashed gray;
text-decoration:none;
}

This can also be useful for forms. Maybe you want a different border for submit buttons...
 
Back
Top