Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: DOCTYPE Disaster.

  1. #1
    Join Date
    Feb 2007
    Posts
    46
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default DOCTYPE Disaster.

    I have created a website with several pages. There is a combination of HTML, a little JavaScript, and an external CSS style sheet. Currently, NONE of the pages have a DTD statement at the top.....and everything works fine (I think).

    However, in reading many sites, I am under the impression that each page MUST have a DOCTYPE statement. So, I attempted to add the one that was most recommended:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

    This gave disastrous results, with images disappearing everwhere. I tried other versions of DTD's, like 4.01 strict, and some of the text colors defined in my CSS disappeared! What's going on? How do I know which DTD is the right one?

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    When you do not have a DOCTYPE, the browser goes into quirks mode, and basically this is what is screwing up.

    If you validate you pages You will see the errors, where they are and can fix them.

    Once the page is valid you should notice that it looks great.

    You can also validate your CSS there
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Feb 2007
    Posts
    46
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    So.....which DOCTYPE should I be using? I have seen so many different ones, and I don't really know which one is right.

    The pages all display and behave properly WITHOUT a doctype. But as soon as I add any sort of doctype declaration, the whole site goes haywire.

    And I can't validate the pages without the doctype.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You don't need a DOCTYPE but one day (in a universe far far away) you may. However, if you are just starting out, a strict HTML 4.01 DOCTYPE is the way to go:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    </head>
    <body>
    
    </body>
    </html>
    You may think your page looks OK without it and without validation but, that is probably just in one version of one browser (the one that you check your work in). To code effectively with no DOCTYPE across browsers is actually a more advanced technique than using the strict DOCTYPE and can have certain advantages. Coding with no DOCTYPE for only one browser is easy but, then your pages must be viewed in that one browser.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Agreed.

    Also, if you are just starting out you can use the transitional doctype to get your page up and viewable.

    Then force the validation to check as strict, fix those errors then switch to Strict when it all works right.

    As John says, you can get away with none right now, but probably not for very much longer.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Also, if you are just starting out you can use the transitional doctype to get your page up and viewable.
    Not a good idea -- you might use (and possibly hinge your design on) something that has no Strict equivalent.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    No, but for someone that is learning, and going from no doctype, using the more forgivable trans type will give them something to look at while they adjust.

    I know for me it really helps. I have had pages act just the way the OP describes, couldn't get it for the life of me. But then putting it in trans first I could see the spots in question.

    Making the move to strict was simplified going from trans type than from no type at all.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  8. #8
    Join Date
    Feb 2007
    Posts
    46
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your sage advice. I have managed to (so far, I think....LOL) put in a Transitional DTD, that does not bugger up the page layouts.

    One more question: (Perhaps this should be a new thread?)

    Why is it that when I do a google search on keywords within the site (words that are text on the main page), as well as keywords that have been placed in the meta name "keywords" statement, the page never comes up on google? What do I have to do to make it detectable by various search engines? Can you tell I'm really really green at this?

  9. #9
    Join Date
    Feb 2007
    Posts
    46
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    At first I thought the lack of search engine success was due to the complete lack of DTD. But now that I have the DTD in there, it's still not coming up with a google search. So what else am I missing, here?

  10. #10
    Join Date
    Nov 2006
    Location
    90 miles north of Las Vegas
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hey Hey!

    Visit this page and submit you site to google's engine, that should fix your problem, however it does take some time to be indexed by google, sometimes weeks, sometimes months!

    http://www.google.com/addurl/

Bookmarks

Posting Permissions

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