View Full Version : doctype or not
12-10-2006, 03:40 AM
I am getting mad, I make really good layouts and all, but when I put in doctypes, it messes up the entire layout in IE but it stays the same in FF, I was wondering, because i know IE freaks out whenever something comes behind the HTML tag if there was a way to write a doctype in the beginning but so it will only write it when someone is using FF.
Or would it just be better to leave the doctype out?
12-10-2006, 04:22 AM
If your layout is working fine in FF and IE without it, then just leave it out. The DOCTYPE tag just tells the browser which HTML/XHTML specification to follow. Most use this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Which is basically for the VERY few browsers (if any) that'll visit your site that don't read CSS.
12-10-2006, 04:51 AM
Internet Explorer goes into backward‐compatibility (quirks) mode when something precedes the document type declaration that it doesn’t recognize. You can continue rendering your document in quirks mode in that browser by sticking a comment before the declaration, though I wouldn’t recommend it.
As for leaving it out entirely, I wouldn’t do that since it makes it more difficult to create inter‐compatible documents. The whole point of using a DTD is that it defines what language and code set you’ve chosen to use and thus how browsers interpret your document. You choose the DTD first, then code around it, not author your document then decide that you’re going to throw it in there just for the heck of it.
Concerning Majoracle’s comment, I don’t know why you would assume that XHTML would be appropriate for a browser that doesn’t read CSS. If you’re aiming for antiquated browsers, you should be using HTML. Even modern browsers like Internet Explorer can’t read XHTML.
12-10-2006, 07:19 PM
Probably the easiest way to force IE to use the doctype that you set, or to prevent IE from defaulting to "quirks" mode would be to simply make your doctype Strict instead of Transitional.
If you use a Strict doctype then a.) your complying with current web standards b.) IE7 and FF should render pages almost identically. c.) it will prevent IE from reverting to quirks mode which could otherwise mess up layouts.
If you would like an example I am in the process of switching over to valid Strict doctype for my pro-bono website. Try to view it in both FF and IE7 and it should not faulter to quirks and the layouts stay the same.
Here is the site test page HERE (http://harvestwhitecounty.com/main_privacypolicy.php)
hope that helps some,
12-10-2006, 10:58 PM
If I may butt in too... :D
People should use the strict doctype anyway when creating a new website as transitional is only meant for old websites transitioning to new standards (but still using non-standard code - kinda like giving them a chance to participate on standards).
You should think of transitonal as "sloppy code" while strict is the only way to go if you're serious about your profession (but not limited to pros).
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.