SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 48
  1. #1
    SitePoint Member hosterduke's Avatar
    Join Date
    Dec 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy What DOCTYPE! to use for my site

    I am somewhat confused with what DTD declaration/!DOCTYPE to use on my site. Currently I have none and it appears to view just fine on Firefox, Chrome, and IE but everything I am reading says you need to have one. Is there a general rule of thumb that you use in determining what DTD to use?

    I located this source of info but I wasn't sure if my site is considered HTML or XHTML so I didn't know what to go with. How to I determine this?

    If your document is HTML, use this:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">

    If your document is XHTML, use this:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

  2. #2
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    If you don't know we, cannot know either... what did you write XHTML or HTML markup? Without seeing a page example or a live page we have no way of being able to tell you either way.

  3. #3
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    You need to specify a doctype on each page otherwise at least IE will go into quirks mode.

    You really should use a STRICT doctype for either html or xhtml. There is no justification for using a TRANSITIONAL doctype for new or recent websites.

    If you can't or won't post your code or a link to it, you can put both doctypes (one at a time) on a page and see which page has fewer errors on the W3C validator. Then fix the code in the page for that doctype until all the errors are gone.

  4. #4
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    <!DOCTYPE html>
    Beautifully simple isn't it?

  5. #5
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by cranial-bore View Post
    HTML Code:
    <!DOCTYPE html>
    Beautifully simple isn't it?
    Except that if the page doesn't have any html5 specific elements, then the html5 doctype declaration is really meaningless and causes markup validation issues. html5 is by no means finalised and will be in development for at least a few more years and even the w3c validator says its html5 validation results should not be relied upon

  6. #6
    SitePoint Member hosterduke's Avatar
    Join Date
    Dec 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thank you for your reply to my thread. The page is www.regexec.com

    Quote Originally Posted by xhtmlcoder View Post
    If you don't know we, cannot know either... what did you write XHTML or HTML markup? Without seeing a page example or a live page we have no way of being able to tell you either way.

  7. #7
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Go with the HTML4 Doctype for that. Font tags? Not good. Keep XHTML off it.

    Regarding your SEO:
    • The title tag is way to long. Search engines will see through the keyword stuffing (probably) and browsers won't display that much text. Doesn't read well for users anyway.
    • Meta keywords are ignored.
    • Meta description is too long. I hear a max of 160 chars thrown around often.

  8. #8
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...having said that one thing HTML5 does do is specify (in the spec) how browsers should handle invalid markup (proper errors such as incorrectly nested tags).
    Previously it was up to individual browsers to decide how to construct the DOM from bad markup. If you're at risk of these errors HTML5 is probably the better choice.

  9. #9
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,329
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by hosterduke View Post
    The page is www.regexec.com
    since you did not close your IMG and BR tags, it's not xhtml

    therefore, you should be using this doctype --
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
      "http://www.w3.org/TR/html4/strict.dtd">
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  10. #10
    SitePoint Member hosterduke's Avatar
    Join Date
    Dec 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks for your time.

    I didn't create the site. I am just trying to maintain it correctly.

  11. #11
    SitePoint Member hosterduke's Avatar
    Join Date
    Dec 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb

    doc.jpg

    Thanks r937


    This is the result of using the code you suggested. As you can see, it creates white gaps between items.

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">

    ---

    cranial-bore

    I also shortened the Title Tag and Meta Description.

    I am not sure what you mean by "Meta keywords are ignored." can you expand please?

  12. #12
    SitePoint Member hosterduke's Avatar
    Join Date
    Dec 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This one seemed to do the trick.
    I tested it on FireFox, IE9, and Chrome.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

  13. #13
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by hosterduke View Post
    This one seemed to do the trick.
    I tested it on FireFox, IE9, and Chrome.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    That doctype is for web sites created bac k in the 20th Century that haven't yet finished getting rid of the HTML 3.2 tags. You shouldn't use it for new sites.

    If using a strict doctype displays the page incorrectly then you have not coded the CSS the right way to get what you want.

    You should fix the CSS to correct the way the page displays rather than moving back into the 20th Century with an old doctype.
    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="^$">

  14. #14
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I meant about the meta keywords is that search engines do not consider them at all when ranking a site, or determining the page content. They are very easily faked because users never see them, so have had zero weight on search results.

    You can drop them and save a little bit of page size.

  15. #15
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by cranial-bore View Post
    You can drop them and save a little bit of page size.
    Unless you decide to implement a script on your own site that uses them. If you do that then the meta keywords tag will be used because you are using it yourself.

    Unless you implement something yourself that uses it though it is a complete waste of space being there as too many sites abused its intended use with search engines in the past and so the search engines now all ignore it completely.
    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="^$">

  16. #16
    SitePoint Member hosterduke's Avatar
    Join Date
    Dec 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks felgall. I was afraid of that. I am a newbie to CSS so I will have to try to figure it out.

  17. #17
    SitePoint Member hosterduke's Avatar
    Join Date
    Dec 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Will do!

    Thank you.

    Quote Originally Posted by cranial-bore View Post
    What I meant about the meta keywords is that search engines do not consider them at all when ranking a site, or determining the page content. They are very easily faked because users never see them, so have had zero weight on search results.

    You can drop them and save a little bit of page size.

  18. #18
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,299
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    <!DOCTYPE html>

    Quote Originally Posted by Max Height View Post
    Except that if the page doesn't have any html5 specific elements, then the html5 doctype declaration is really meaningless and causes markup validation issues.
    It's not really a specifically HTML5 doctype, though, but a doctype that can be used with any version of HTML. And it's nice and simple. I don't see any reason not to use it.

  19. #19
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by ralph.m View Post
    <!DOCTYPE html>
    It's not really a specifically HTML5 doctype, though, but a doctype that can be used with any version of HTML. And it's nice and simple. I don't see any reason not to use it.
    ah, ok

    But I based my post on what I read in this post discussing the above doctype

    So who is correct - you or deathshadow60?

  20. #20
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,299
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by Max Height View Post
    I based my post on what I read in this post
    I think his point there is that the rules for that new doctype are very forgiving, turning a blind eye to HTML practices that are not allowed in XHTML (such as non-closed elements). But I guess I shouldn't speak for DS.

  21. #21
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    That's what I thought he was saying as well.

    So although I was wrong saying the doctype is html5 specific, I do agree with ds60's view and hence the second part of my comment:

    Except that if the page doesn't have any html5 specific elements, then the html5 doctype declaration is really meaningless and causes markup validation issues.
    and so I wouldn't recommend using it unless there is no other option of course.

  22. #22
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,299
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by Max Height View Post
    Except that if the page doesn't have any html5 specific elements, then the html5 doctype declaration is really meaningless and causes markup validation issues.
    But the point is, it's not an HTML5 specific doctype. All HTML elements are covered by that doctype; and HTML5 is not a new animal: it's just HTML with a few new elements. The doctype will continue to be the same even as further elements are added (even if they get collectively dubbed "HTML6" or whatever). I'm not sure what markup validation issues you might be referring to.

    Basically you need some kind of doctype to prevent the browser jumping into quirks mode, but which you use doesn't seem to matter a whole lot.

  23. #23
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by ralph.m View Post
    Basically you need some kind of doctype to prevent the browser jumping into quirks mode, but which you use doesn't seem to matter a whole lot.
    ok maybe I'm misunderstanding something here.

    I totally agree that a doctype must be used. But I am under the impression that if you have html5 specific elements in the html then <!DOCTYPE html> must be used and that if you don't have any html5 specific elements then you shouldn't use <!DOCTYPE html>, but instead use either the Strict doctype for either html or xhtml, depending on your code.

    The validation issues I refer to if using <!DOCTYPE html> are the same as mentioned by ds60 in the other thread and also I note that the w3c validator also mentions that its validation results for doctype <!DOCTYPE html> should not be relied upon for now at least.

    I guess what I am saying is that if I stick <!DOCTYPE html> on top of my html or xhtml code that doesn't contain any html5 elements, I am under the impression that the w3c validator might not detect errors in the code it otherwise would if using one of the Strict doctypes instead. Is my perception correct?

  24. #24
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,299
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by Max Height View Post
    I am under the impression that if ... you don't have any html5 specific elements then you shouldn't use <!DOCTYPE html>, but instead use either the Strict doctype for either html or xhtml, depending on your code.
    No, it's fine to use the new doctype for any kind of site now, as many are doing. It's neater and simpler and has no negative side effects. That doctype covers all HTML elements.

    I guess what I am saying is that if I stick <!DOCTYPE html> on top of my html or xhtml code that doesn't contain any html5 elements, I am under the impression that the w3c validator might not detect errors in the code it otherwise would if using one of the Strict doctypes instead. Is my perception correct?
    In my experience, it has certainly picked up any errors that I've made with no problem. Of course, because it is not bound to some of the stricter rules of XHTML*, it won't hassle you about things like unclosed elements like LIs etc. (so I believe, anyhow, as I never leave elements unclosed). Perhaps when the w3c says it's not totally reliable yet it means in terms of the newer elements that aren't really real-world ready yet.

    If you are worried, you could always swap to another doctype for validation purposes. But then I guess you might as well be done with it and use that other doctype anyway. I've just converted to the simpler doctype because I don't use XHTML anyway and because it's much neater.

    There are people around here who know far more than me about all this stuff and have argued passionately against the merits/worthiness of the new doctype, but I've given in now, as I like it's simplicity and I've found no problems with its use at all.

    *EDIT: actually, I may be wrong there anyway, as there is also XHTML5. Perhaps that's a different option to validate against, but I haven't checked.

  25. #25
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by ralph.m View Post
    No, it's fine to use the new doctype for any kind of site now, as many are doing. It's neater and simpler and has no negative side effects. That doctype covers all HTML elements.
    If someone is not concerned if their code validates or not then I suppose you can use the doctype on any document.

    But I just did a little experiment to confirm what you said about it not hassling you about some unclosed elements. In this sample code

    Code:
    <!DOCTYPE HTML>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
            <title></title>
        </head>
        <body>
            <ul>
                <li>item 1
            </ul>
        </body>
    </html>
    the w3c validator passes it without any errors even though a Strict html or xhtml doctype would have generated a validation error due to the missing </li>

    For me, who likes the rigidity of xhtml, the fact the w3c validator passes the above code is a deal breaker for using the above doctype unless there is no another option, like when using html5 specific elements.

    I also note that on the w3c valid doctypes page it lists <!DOCTYPE HTML> as being for HTML5 only and also states that it is not standard yet. However, it doesn't say it cannot be used for other documents as well. But by not listing it for the other document types, I guess they are indirectly discouraging the use of <!DOCTYPE HTML> for anything other than documents that contain html5 specific elements.


Tags for this Thread

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
  •