Welcome to WebmasterWorld Guest from 54.226.241.8

Forum Moderators: incrediBILL

Message Too Old, No Replies

HTML Doctype ruined my page

     

one_mind

4:20 am on Nov 26, 2005 (gmt 0)

5+ Year Member



Hi,

I had the following doctype on my page:

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

And all was good until someone pointed out that it was incomplete as it was missing the url. So i added this doctype:

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

But now my site is all messed up. Titles and words have moved to different locations, forms have different border thickness and things just look different.

Why is this? I just deleted the url so my page has gone back to normal. Is it such a big deal if i dfont have a doctype? My site looks fine in all major browsers as is and i cant use the wc3 validator anyway because all my pages are php and covered with scripts.

Any info would be great.

Thanks

drhowarddrfine

4:34 am on Nov 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since you are using an incomplete doctype then you were coding to an unknown set of 'rules'. Now that you've informed the browsers the proper set of rules, they are conforming to that set. So your code was wrong in the first place. I'm surprised you said it works in all the major browsers but I haven't seen your code.

It doesn't matter if you use script for your page, it will still validate if you do it correctly. If it's not validating then you are doing something wrong.

one_mind

5:41 am on Nov 26, 2005 (gmt 0)

5+ Year Member



Thanks,

While my code doesn't validate, it still works fine in ie and firefox so i dont think i'll bother till i rewrite the site at a later date.

Cheers

kaled

11:01 am on Nov 26, 2005 (gmt 0)

WebmasterWorld Senior Member kaled is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Not sure about FF and Opera, but omitting the url from the doctype has the explicit effect of enabling quirks mode in IE. In this mode, the box-model used is different - width and height includes the padding (and margin possibly).

Try the forum83 - CSS.

Kaled.

Robin_reala

1:55 pm on Nov 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep, it's quirks mode coming into play. Invented in IE5 on the Mac, nearly all major browsers now employ this. The idea is that if you use a full doctype then you know what you're doing and are telling the browser to render according to the rules laid down by the specs. If you don't use a doctype or use a partial one then you're telling the browser that you don't care particularly about the exact rules. In quirks mode browsers try to emulate the idiosyncrasies of previous browsers - for example IE6 in quirksmode will use IE5's broken box model, and Mozilla will emulate Netscape4's inability to inherit text size in ems into tables.

The problem with this is in quirksmode not all browsers have the same quirks - that's the point of standards mode.

tedster

3:55 pm on Nov 26, 2005 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Here's a thread with a lot more detail about Quirks Mode and Standards Mode [webmasterworld.com]

encyclo

6:22 pm on Nov 26, 2005 (gmt 0)

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member



It is not a huge deal using a "half doctype" when you are dealing with an established site designed to work in quirks mode - it will enable you to validate your pages (just because they are dynamic doesn't mean that you can't correct errors in the generated markup) whilst ensuring that modern browsers take into account the fact that the page is not fully compliant woth the latest specifications.

You should always use a full doctype (with the URL) if you are building pages with CSS positioning instead of tables as the standards-compliant parsing mode makes it much easier to ensure cross-browser consistency.

one_mind

5:34 am on Dec 4, 2005 (gmt 0)

5+ Year Member



Thanks all,

Its been a while but have now decided to bite the bullet and use the full doctype and fix up the errors.

I have a couple of questions about it. First, is this doctype here the proper current one to use?

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

Also, I am developing my site on my home computer that is sometimes not connected to the internet. If i'm not connected to the net, how can the browser contact that dtd at the specified url? Does is switch back to quirks mode when offline?

Also, is there a place that lists what code u can and cant use in html 4.1 using the above dtd?

Thanks :)

kaled

11:33 am on Dec 4, 2005 (gmt 0)

WebmasterWorld Senior Member kaled is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The contents of the url is typically ignored by browsers but may be used by validators. Rendering will be identical whether you are online or not.

Kaled.

Farix

2:14 pm on Dec 4, 2005 (gmt 0)

10+ Year Member



I would suggest that you try to go for HTML 4.01 Strict with the following doctype:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

As for reference on what can and can't be used, the original W3C docs are a good place to start for both HTML [w3.org] and CSS [w3.org].

 

Featured Threads

Hot Threads This Week

Hot Threads This Month