Anyway of adding doctypes without messing up the layout?

Discussion in 'HTML & Website Design' started by emkay, Jun 28, 2006.

  1. #1
    Whenever I seem to add a doctype, it messes up my site layout. How can I add the doctype properly without problems?
     
    emkay, Jun 28, 2006 IP
  2. ServerUnion

    ServerUnion Peon

    Messages:
    3,611
    Likes Received:
    296
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You will have to make sure you remove any special characters that are not needed. Extra spaces, line breaks etc... Let us know what you come up with. Good luck...
     
    ServerUnion, Jun 28, 2006 IP
  3. emkay

    emkay Guest

    Messages:
    351
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Oh I'll try that, thanks.
     
    emkay, Jun 28, 2006 IP
  4. dilipsam

    dilipsam Well-Known Member

    Messages:
    606
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    135
    #4
    You can not write just any code and just insert your doc type declarations.

    For instance XHTML, requires you properly nest your tags. Write your code according to what doc type fits in.

    Let me know if you need any help.
     
    dilipsam, Jun 28, 2006 IP
  5. emkay

    emkay Guest

    Messages:
    351
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    so the code has to be valid for the doctype to work?
     
    emkay, Jun 29, 2006 IP
  6. ServerUnion

    ServerUnion Peon

    Messages:
    3,611
    Likes Received:
    296
    Best Answers:
    0
    Trophy Points:
    0
    #6
    you may want to try this, as it will let you get away with a few issues in the code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    
    Code (markup):
    You may then check you code here: http://validator.w3.org/
     
    ServerUnion, Jun 29, 2006 IP
  7. emkay

    emkay Guest

    Messages:
    351
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Ok thanks for the help, I'll try it out
     
    emkay, Jun 29, 2006 IP
  8. FeelLikeANut

    FeelLikeANut Peon

    Messages:
    330
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #8
    More or less, yes.
     
    FeelLikeANut, Jun 29, 2006 IP
  9. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #9
    The browser uses the DTD to decide whether to render the html as standard or in a backward compatible (quirks) mode. IE and Opera are the main browsers greatly affected by the DTD switch. IE, because IE<6 is really crappy about standards, and Opera because it is an IE wannabe in quirks mode.

    Firefox and Safari will show fewer differences because they've always tried to be standards compliant.

    The browser does not use the DTD, otherwise. The validator, otoh, has to have a DTD in order to know which ruleset to validate against. A loose or transitional DTD says to the validator, "any html element or attribute that has ever been valid is ok". A strict DTD says, "go by the book".

    A loose DTD is handy if you must work with legacy docs that contain deprecated or obsolete markup, and the budget won't allow for a complete clean-up. There is no sane reason to use deprecated or obsolete markup on new documents, so they should always have a strict DTD.

    cheers,

    gary
     
    kk5st, Jun 29, 2006 IP