Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: doctype or not

  1. #1
    New Coder
    Join Date
    Aug 2006
    Location
    Kansas, USA
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    doctype or not

    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?

  • #2
    Regular Coder
    Join Date
    Nov 2006
    Posts
    246
    Thanks
    13
    Thanked 26 Times in 24 Posts
    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.

  • #3
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,300
    Thanks
    28
    Thanked 275 Times in 269 Posts
    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.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #4
    Regular Coder
    Join Date
    May 2006
    Posts
    290
    Thanks
    6
    Thanked 14 Times in 14 Posts
    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

    hope that helps some,

    -trigger

  • #5
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,636
    Thanks
    6
    Thanked 1,003 Times in 976 Posts
    If I may butt in too...

    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).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •