SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: which doctype?

  1. #1
    SitePoint Zealot
    Join Date
    Nov 2008
    Location
    UK
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    which doctype?

    I am really confused about what effect different doctypes have.

    STRICT means no inline styling?
    You need FRAMESET if you want to use frames?

    But what is the difference between using
    Code HTML4Strict:
    <!DOCTYPE html PUBLIC
      "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    and
    Code HTML4Strict:
    <!DOCTYPE HTML PUBLIC
      "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd">
    ?

    What will work, or won't ?

    What is best practice?

  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)
    The first is XHTML 1.0 the second is HTML 4.01 so if you are writing HTML chose the second one or better still use Strict grammar rather than Transitional.

  3. #3
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,366
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Here are a couple of links to keep you busy for a few hours.

    Activating Browser Modes with Doctype
    Eric Meyer on CSS: Picking a Rendering Mode

  4. #4
    SitePoint Addict EarlyOut's Avatar
    Join Date
    Mar 2011
    Location
    Sector R
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to add to the joy of the subject, there's a world of difference between what's allowed with a given DOCTYPE, and what will actually work in a browser. Just a quick example: in the Strict DOCTYPES, you can't use a <center> tag. If you do, the page will fail to validate as "proper" HTML. Yet pretty much every browser will, in fact, center the material between those tags, DOCTYPE be damned.

    "Strict" does not mean "no inline styles." It means, among other things, that styling (generally, with some exceptions for tables, for example) uses CSS, not HTML attributes or tags. So, this is OK in a Strict page:

    Code:
    <span style="color: red;">Red text</span>
    But this isn't kosher:

    Code:
    <font color="red">Red text</font>
    But again, either one will produce red text in any browser. Go figure.

    My two cents: coding for "Strict" and validating your pages against a Strict DOCTYPE probably gives you the best chance of having your stuff render properly in all browsers, and gives you some future-proofing.

  5. #5
    SitePoint Addict EarlyOut's Avatar
    Join Date
    Mar 2011
    Location
    Sector R
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW, the "Important" threads at the top of this forum section are also good reading on the subject.

  6. #6
    SitePoint Zealot
    Join Date
    Nov 2008
    Location
    UK
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you guys. Explanations that don't start somewhere above my head and a real-world example, just what I was after.


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
  •