Forum Moderators: open

Message Too Old, No Replies

Adding doctype messes up css positioning

any possible reasons?

         

annej

5:33 pm on Apr 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Adding doctype to just two of my pages completly throws the css positioning. It doesn't happen anywhere else and as I validate I can't find any reason this is happening.

Has anyone else experienced this or does anyone have an idea of what might be causing this?

pageoneresults

5:50 pm on Apr 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Adding doctype to just two of my pages completly throws the css positioning.

Which DTD? And, it is the full DTD or a shortened version that throws the browser into Quirks mode?

Is the CSS valid? I'm assuming it is, just need to ask. ;)

annej

6:41 pm on Apr 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It was <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

The strange thing is that the page works fine if we remove it. I'll look at the CSS again but it seems to me there should be no relationship between the css and doctype. But then I'm kind of clueless about this.

encyclo

7:44 pm on Apr 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you're converting an old page, you might want to start with this doctype:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

The difference between the doctypes is that the "full" version ensures "standards-compliance mode" in modern browsers, where the specifications are much more closely-followed. The shorter doctype (without the URL) triggers a special, more backwards-compatible "quirks mode". See tedster's excellent library thread Quirks Mode vs. Standards Mode [webmasterworld.com] for more information.

Ideally, you should move to using standards-compliance mode for all documents.

Wlauzon

4:01 am on Apr 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually what is happening is the the DOCTYPE is now making it work like it should - and it is broken :D

annej

6:19 pm on Apr 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wlauzon, That is probably only too true. (sigh)

henry0

10:34 pm on Apr 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Once I had the exact same problem
Resoved it by using
<<<
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml 1-transitional.dtd">
>>>