Previous Message
Next Message

after two days, doctype matters...

Sent by Bob Easton on 6 March 2005 11:11


Anthony wrote:
> I just spent the last two days trying to figure out
> why I couldn't get the correct padding/spacing in my
> nested UL menu.
> 
> After finally debugging the example from listomatic I
> narrowed it down to the doctype.
> 
> Maybe this is a rookie move, I've been developing
> sites for 7 years, and haven't ever really needed a
> specific doctype until now.
> 
> For the nesting to work properly in IE, you need to
> have a doctype of:
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
> Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> 
> ...
Yes, !DOCTYPE matters. For a long time IE had a broken box model.  It 
calculated widths incorrectly. That was resolved in IE6, which now 
calculates (mostly) to the CSS specifications.  To accommodate these 
differences, browser publishers use the !DOCTYPE to determine which way 
the browser should behave.  Without a !DOCTYPE, IE and some other 
browsers will go into "quirks mode" calculating widths the wrong way. 
Use a valid !DOCTYPE and the browser behaves in standards mode.

Read more:
A List Apart article about !DOCTYPEs
http://www.alistapart.com/stories/doctype/

The ORIGINAL box model article.  Note, there are many more efficient 
hacks since this article was written.  However, it has great illustrations.
http://www.tantek.com/CSS/Examples/boxmodelhack.html


-- 
Bob Easton

______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: