Which DOCTYPE should I use?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Melissa De Luca
    New Member
    • Dec 2010
    • 9

    Which DOCTYPE should I use?

    i There,

    I finally launched my site and it looks good on safari and firefox, however in Explorer some of the pages are wonky. It looks as if some of the classes are not properly applied. I find it weird considering there are other pages on the site with the same classes applied to them and are showing correctly. I tried searching for solutions online and I was reading articles about DOC TYPES but I can't get my head arund it.

    What kind of DOC TYPE should I use? Would anyone happen to know the code for it?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    basically you can use 2 doctypes: HTML 4.01 or HTML5. HTML5 is recommended if you plan to use some of its new functionality/elements.

    HTML 4:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
                "http://www.w3.org/TR/html4/strict.dtd">
    HTML5:
    Code:
    <!DOCTYPE html>
    if you absolutely need frames, you’ll need the Transitional or Frameset variant of HTML 4.

    PS. don’t forget to validate your code: http://validator.w3.org/

    Comment

    • drhowarddrfine
      Recognized Expert Expert
      • Sep 2006
      • 7434

      #3
      Doctype is short for "Document Type Definition" and DTD. Essentially, it's the rules set for each element on the page. If you don't define which set of rules you are using ahead of time, then you are in 'quirks mode' and it's like 1998 all over again.

      New web pages should always use the strict doctype as shown by Dorm above. However, there is no problem using the so called "html5 doctype" since this puts all browsers in 'standards mode' which is the same thing as HTML 4.01 strict.

      The doctype is the very first thing you start with on a page and never, ever change it.

      Comment

      • Melissa De Luca
        New Member
        • Dec 2010
        • 9

        #4
        GREAT! Thank you :)

        what do you mean by frames? I am mainly using tables and ap divs? Can you give ma an example?

        Comment

        • Melissa De Luca
          New Member
          • Dec 2010
          • 9

          #5
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

          That is the doc type that was automatically in my code. So just confirm I need to change this to the code provided by dormilich? Just confused because "drhowarddrfine " says never to change it? :s
          Last edited by Dormilich; Jan 21 '11, 12:48 PM. Reason: name spelling correction

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            if you don’t know about frames, leave it as such (frames are outdated anyways)

            Comment

            • drhowarddrfine
              Recognized Expert Expert
              • Sep 2006
              • 7434

              #7
              @Melissa,
              The transitional doctype is for web pages containing older, deprecated markup that you are transitioning or combining with newer pages. Particularly, this helps with validation as the older markup won't get flagged as errors. So new web pages shouldn't be using deprecated markup and, therefore, no one has any need for the transitional doctype.

              But once you've started working on a page, you should never change the doctype you are using. Change the doctype and you are changing the rules you are telling the browser you are using and this may alter the rendering of the page. So don't do that.

              Comment

              • Melissa De Luca
                New Member
                • Dec 2010
                • 9

                #8
                @drhowarddrfine
                So what do I have to do in order to make my website look the same in all browswers? If my current DOCTYPE is was I indicated in a previous post?
                Thanks :)

                Comment

                • drhowarddrfine
                  Recognized Expert Expert
                  • Sep 2006
                  • 7434

                  #9
                  You can use that doctype without issue. Getting pages to work in all browsers is not much of a problem. Only IE is a problem. The worst browser on the planet, inept at best, and 13 years behind all others in modern standards and practices. It's an embarrassment to Microsoft.

                  So the only real "trick" is, test your page first in anything but IE. If you add something and test in Firefox, glance at Chrome/Safari/Opera to see how it looks there. If it looks fine, and you validated your HTML and CSS, then you know your markup is correct.

                  Then look at IE. Chances are something will be screwed up. Just make sure you aren't trying to "fix" your markup for IE's sake. That's how so many people run into trouble. There are hundreds of web sites dedicated to fixing IE's problems as the problems and fixes are well known. (There are none, and none needed, for any other browser.)

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    www.positioniseverything.net for example

                    Comment

                    Working...