www.webdeveloper.com
Results 1 to 14 of 14

Thread: Doctypes ???

  1. #1
    Join Date
    Nov 2002
    Location
    Peterborough, UK
    Posts
    166

    Doctypes ???

    Can someone please give me a brief guide to what DOCTYPEs are for and how I should specify one for my web pages. Also, how do I choose which DOCTYPE to use ?

    I am using PHP/MySQL to build my site, will this have any effect on the choice of DOCTYPE ?

    Thanks

  2. #2
    Join Date
    Dec 2002
    Location
    Taiwan
    Posts
    1,297
    The doctype gives some basic information on the content of your page. The information it finds there helps the browser to interpret your page correctly, although most sites seem to work fine without them. Here's a nice article on choosing a Doctype for your site:

    http://htmlhelp.com/tools/validator/doctype.html

    Using PHP an MySQL shouldn't make any difference in your doctype since they're both server-side. But after you've chosen your doctype and placed it into your webpage you should run it through W3C's validation service to check for errors:

    http://validator.w3.org/

  3. #3
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    This is a very nice article: http://www.alistapart.com/stories/doctype/

  4. #4
    Join Date
    Nov 2002
    Location
    Peterborough, UK
    Posts
    166

    Thanks

    Thank you both.

    I will check out those articles this evening.

  5. #5
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    As someone who has written a DTD or two let me fill in a few holes left by those articles, a DOCTYPE does three things:

    1) As mentioned, it tells the browser that you know what you are doing;

    2) It tells validators what version of HTML you are using;

    3) It defines the entities.

    One above is discussed in one of those articles. As to two, the different versions of HTML have very different rules and it is a important to keep them straight as it is difficult to remember what rules go with what HTML version you are using. And everybody makes mistakes. It is very important to always run your page through a validator and the validator cannot work without knowing what HTML version you are using. The entities are things like "™" and they are defined in the DTD and can be defined in the DOCTYPE file. Browser support is iffy to say the least, but you can define your own entities and you can even use them to include the contents from other files.

    Most of that stuff is built into the browser and you don't want to go about playing with entities unless you are using XML.

    But it is important to use the DOCTYPE that corresponds to the version of HTML that you are using.

    HTML 3.2 is the old kind of HTML. It's what most people think of when you say HTML. Anything written in HTML 3.2 will work on all graphical browsers.

    HTML 4.01 Strict is the gold standard. Anything written in HTML 4.01 will in all browsers, be the graphical or non-graphical. This is the one all good web author's use.

    HTML 4.01 Transitional includes all of 3.2 and all of 4.01 Transitional. 4.01 Strict relies upon CSS for layout and presentation. The idea was to allow web authors to create a page that like 4.01 Strict documents would work on all browsers but that like 3.2 documents would look good on all graphical browsers. In practice web authors use it to get away with sloppy HTML, ending up with documents that don't work on all graphical browsers and don't work on non-graphical browsers. It's best to not use the transitional DTD.

    HTML 4.01 Frameset is for framesets and it includes all of the 4.01 Transitional DTD for your NOFRAMES element. This one has everything including the kitchen sink.

    XHTML 1.0 Strict, Transitional and Frameset are just the HTML 4.01 DTDs in XML.

    XHTML 1.1 is HTML 4.01 Strict in XML.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  6. #6
    Join Date
    Sep 2003
    Posts
    10

    URGENT! doctypes again

    i'm opening up this discussion again be/c i'm having many problems with doctypes. i was told i need doctypes and i inserted one and this is what it did:
    http://www.dolphindancephotography.com/home.htm
    this is a mock page but i've tried all different types... am i missing something? thanks
    Last edited by dolphindance; 09-10-2003 at 07:39 PM.

  7. #7
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    What seems to be your problem?

  8. #8
    Join Date
    Sep 2003
    Posts
    10

    problems

    when you go to my page http://www.dolphindancephotography.com/home.htm you can see my navigation bar a contact info box and a bunch of photos pile up in the left top corner. the bar and contact box are supposed to be on the bottom, and the photos on top of the different shapes at top. it's all whacked out - and that only happened when i added the doctype.

    thanks for your attention!

  9. #9
    Join Date
    Nov 2002
    Posts
    2,632

    Re: problems

    Originally posted by dolphindance
    when you go to my page http://www.dolphindancephotography.com/home.htm you can see my navigation bar a contact info box and a bunch of photos pile up in the left top corner. the bar and contact box are supposed to be on the bottom, and the photos on top of the different shapes at top. it's all whacked out - and that only happened when i added the doctype.

    thanks for your attention!
    I just wanted to say I am still working on fixing your problem, but I hit a snag with the graphics. I did post a thread in the graphics forum about it. I also now see the menu bar, so that will be easy to handle since I use the same kind of one for my own site.

  10. #10
    Join Date
    Sep 2003
    Posts
    10

    thanks

    hey, thanks! i still don't understand why doctypes won't work for my site. i've also made many changes to the site - the engineers are still trying to figure out my server problem so they've had me change a lot of the file names. well...must admit, i had names with spaces and stuff that i didn't know about thanks for all your help.

  11. #11
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,137
    Since we are talking about XHTML,and there was a PHP/MySQL part to this thread as well, here is a very serious problem???? with PHP I noticed( or since I am a newbie when it comes to php,I might not know the answer.. )

    If you use an XHTML page that starts with
    <?xml version="1.0"?> tag, php does not load such page....f**king crap....you have to remove those tags....by default all of my pages have this statement and strict XHTML doctype,I was bummed to find out that I had to remove that from all of my pages to work in PHP
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  12. #12
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Yep, with short tags enabled in the php.ini file, you will have to use one of these two things:

    You can just define your content type with this line (which is my favorite way of doing it):

    Code:
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    With the above way, you will also avoid IE6 going into quirks mode when it runs across the XML prolog.

    Or, if you like to use the XML prolog, you can use this:

    PHP Code:
    <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"?>
    Note to Khalid -

    If you want your pages to work as is, just turn off short tags in your php.ini file. That should do it...

  13. #13
    Join Date
    Nov 2002
    Posts
    2,632
    Without a Doctype, a browser goes into quirks mode, and the browser does it's best to figure out what version of HTML to you are using. I can't remember what the defaults are for quirks mode, but I know Netscape goes back a ways. This means your site would be read based on a old broweser that may not know how to handle some of the code you used even if it was valid. I maybe wrong in this, but I'm sure somebody will correct me if I am. I do know that having invalid code and a Doctype leads to funny things happening.

    Khalid Ali, since I use XHTML for my site, I did run into a problem with using <?xml version="1.0"?> I just took it out because it does still validate without it.

  14. #14
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,137
    Originally posted by spufi

    I just took it out because it does still validate without it.
    Thanks for response,however,you seem to overlook the point, that is you have to use a work around to make it work....
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

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