SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru Zygoma's Avatar
    Join Date
    May 2006
    Location
    York, Uk
    Posts
    916
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Whats the consequence of getting your <!DOCTYPE> wrong?

    Buongiorno from 10 degrees C wetherby UK :-)

    I understand a HTML page has to start with a !DOCTYPE line but I wonder what are the consequences if your web page was not written in HTML 5 and you strated the first line with <!DOCTYPE html>.

    Grazie tanto,
    David
    I have had a perfectly wonderful
    evening, but this wasn't it-
    Julius "GROUCHO" Marx - 1890-1977
    http://www.davidclick.com

  2. #2
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,108
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    no consequence.

    It will just change the rules used for validation services like http://validator.w3.org/

  3. #3
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,888
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Zygoma View Post
    I understand a HTML page has to start with a !DOCTYPE line but I wonder what are the consequences if your web page was not written in HTML 5 and you strated the first line with <!DOCTYPE html>.
    Because HTML5 used the principle of "pave the cow-pats", the idea was that pretty much anything that was valid in HTML4 would continue to be valid in HTML5, to maintain backwards compatibility. There are only a tiny number of things that are likely to become invalid with the move to HTML5, so it is unlikely to be a problem. Even if you do use invalid code (whether outdated or just plain wrong), with HTML (but not XHTML) browsers are generally as forgiving and accommodating of bad code as they can be, so they will do their best to show what they think you meant.

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,201
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by Zygoma View Post
    ... if your web page was not written in HTML 5 ...
    Remember that "HTML5" is just HTML, so as long as your page is HTML, that doctype is fine. The doctype you have cited is intended for HTML (as it indicates itself), that's all. As said, the validator looks at what doctype you've cited to decide what set of rules to validate against, but that's kind of irrelevant to the actual web page and how it functions in a browser. I now use that doctype in all my pages—because it's nice and simple—but I don't use any of those silly elements like <nav> and <section>.

  5. #5
    SitePoint Guru Zygoma's Avatar
    Join Date
    May 2006
    Location
    York, Uk
    Posts
    916
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Brill thanks :-)
    I have had a perfectly wonderful
    evening, but this wasn't it-
    Julius "GROUCHO" Marx - 1890-1977
    http://www.davidclick.com

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,825
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    HTML 5 is using the short version of the HTML 2 doctype so all that doctype tells anyone is that the HTML is not version 1.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •