www.webdeveloper.com
Results 1 to 15 of 15

Thread: <!doctype ...> what does it mean?

  1. #1
    Join Date
    Apr 2005
    Posts
    210

    <!doctype ...> what does it mean?

    I created a CSS drop-down menu, all are fine.

    parent-child sections are used in CSS, look like:
    Code:
    #parent > child{...}
    #parent:hover > child{...}
    ...
    Actually, the menu code was copied from somewhere then modified by me.
    At beginning of the html page, I see:
    Code:
    <!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd">
    then, I reduce the code to:
    Code:
    <!doctype >
    All are still fine.
    But, menu doesn't work if without last <!doctype >.

    I am wondering why the piece of code <!doctype > is so important? it sounds saying nothing.

    Could you explain?

    Thanks.

    .

  2. #2
    Join Date
    Feb 2008
    Location
    NW Washington State
    Posts
    1,856
    The DOCTYPE describes to the Web browser displaying the page which set of rules to use when parsing (reading and displaying) the page.
    So using one set of rules will display one way. Using a different set of rules means the page will display some other way.
    More info here:
    http://www.w3schools.com/tags/tag_doctype.asp
    Best wishes,
    Eye for Video
    www.cidigitalmedia.com

  3. #3
    Join Date
    Mar 2011
    Posts
    1,136
    To put a finer point on this issue, the <!DOCTYPE> is particularly important to web designers because using a complete <!DOCTYPE> statement sets browsers to Standards Compliance Mode in which they are all at least *trying* to render pages according to the W3C Standards. Using an incomplete <!DOCTYPE> or omitting it entirely, leaves browsers in what's called "Quirks Mode" in which they render pages with their own methods - each of which is different to one degree or another. Simply put, if your page relies on anything more sophisticated than <table>s and <font> tags, a complete <!DOCTYPE> is vital for cross-browser compatibility.
    Rick Trethewey
    Rainbo Design

  4. #4
    Join Date
    Apr 2005
    Posts
    210
    My question is not clear.

    does the blank <!doctype > include default version, link or something else?

  5. #5
    Join Date
    Mar 2011
    Posts
    1,136
    Your example "<!doctype>" is invalid and does nothing. Browsers will use Quirks Mode if you use that. Use a complete <!DOCTYPE> that includes the document type and a URL so that the browser will use Standards Compliance Mode. For example:

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

  6. #6
    Join Date
    Jan 2011
    Posts
    117
    No, that's not true.
    The <!doctype> declaration will enforce all browsers to go into standards HTML mode. Same as with the script tag which will always default to its native "JavaScript" language not some other random or unconventional programming language if not declared.

    Only the most recent FX edition seems to have introduced a bug, which makes it complain. But they seem to have forgotten that the default browser language (and the reason they exist) is was and always will be: HTML code interpretation.

    Anyway until FX reverts to complying with the convention they always complied to, going with <!DOCTYPE html> declaration will do you no harm.

  7. #7
    Join Date
    Feb 2008
    Location
    NW Washington State
    Posts
    1,856
    Troy III, I suggest you re-read the other posts.
    EfV

  8. #8
    Join Date
    Apr 2012
    Posts
    22
    Just choose a specification you are going to follow and use its doctype - http://www.w3schools.com/tags/tag_DOCTYPE.asp

    If "HTML 4.01 Transitional" doesn't dork, try "XHTML 1.0 Transitional" I believe they are most popular now.

  9. #9
    Join Date
    Mar 2012
    Posts
    1,278
    Basically: If it was working fine with the HTML 4.01 doctype why change it??? Or if you must fiddle, read the manual!

  10. #10
    Join Date
    Nov 2002
    Posts
    2,632
    Quote Originally Posted by jedaisoul View Post
    Basically: If it was working fine with the HTML 4.01 doctype why change it??? Or if you must fiddle, read the manual!
    And if one is going to change it to the more recent HTML 5 version, at least make sure it's correct, <!DOCTYPE HTML>.

  11. #11
    Join Date
    Mar 2012
    Posts
    1,278
    Quote Originally Posted by spufi View Post
    And if one is going to change it to the more recent HTML 5 version, at least make sure it's correct, <!DOCTYPE HTML>.
    I've been thinking about 5, but how well supported is that?

  12. #12
    Join Date
    Nov 2002
    Posts
    2,632
    It mostly needs tweaks for IE(surprise) but I think it's doable. You still need to learn were to put stuff as some of the tag aren't as straight forward as you think they should be. <section>, <aside>, <header>, and <footer> are good examples of tags that have flexibility. I would definitely read up on it to help sort it out. I'm going through a book on it and making a mock up from what I learn. There is also a number of technologies that are getting lumped into HTML 5 as well. The Missing Manual series has a HTML 5 book that covers the topics and it's the one I'm going through.

    Here's the basics of code to make it more cross browser friendly. I might add I could see adding the <video> and <audio> tags as block level display as well.

    Put into <head> as IE doesn't even recognize the HTML 5 tags and this counters it.
    Code:
    <!--[if lt IE 9]>
        <script src="http://html5shim.googglecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    Put into CSS. Some browsers don't give these tags block level display.
    Code:
    /* HTML 5 Block Tags */
    article, aside, figure, figcaption, footer, header, hgroup, nav, section {
        display:block;
    }

  13. #13
    Join Date
    Mar 2012
    Posts
    1,278
    Thanks for the advice.

  14. #14
    Join Date
    Jan 2011
    Posts
    117
    Quote Originally Posted by Eye for Video View Post
    Troy III, I suggest you re-read the other posts.
    EfV
    I suggest you read mine alone.

  15. #15
    Join Date
    Feb 2012
    Location
    Bokaro Steel City (Jharkhand), India!
    Posts
    194
    I am in love with HTML5! <3
    HTML Code:
    <!doctype html>
    Last edited by TheAliveWinner; 05-03-2012 at 09:48 AM.
    "It will never rain roses: when we want to have more roses, we must plant more roses." - George Eliot

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles