SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,276
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)

    Doctype questions

    Hallo monks and gurus,

    I have had a few transitional pages for some forms which required (if I'm going to support scriptless visitors) target="blank". I was copying and pasting the transitional doctype as this:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01  Transitional//EN"
       "http://www.w3.org/TR/html4/transitional.dtd">
    The above validates with no questions. However after some copying and pasting I did start to get a warning-- that the declaration was not good and to choose "loose.dtd" which, if you look at their recommended list, is the only option for Transitional. There is no "transistional.dtd" and I have no clue where I got it from (way back when I first used it, I'm pretty sure I googled "HTML transitional doctype" and got it from a w3 page).

    The difference? The "warning" dtd has only one space between the words HTML 4.01 and Transistional. The "validating" dtd has two spaces. This will bring up a warning:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/transitional.dtd">

    If the transitional.dtd doesn't actually exist (not on the list anyway) then how can it possibly validate? If two spaces was enough to set this off, then could possibly any accidental spaces make any document I write seem to validate? (note, any errors in the document are indeed pointed out by the validator and with either of the transitional doctypes, the "target" attribute is allowed, so it IS following the transitional rules.)

    Hmmm, I can't even find where I got that transitional.dtd line. I know I hit teh googles and I know I didn't just pick it off some crap site. Hm...

    Anyway, any enlightenment? If the transitional statement is totally wrong I have a heap of pages to change : ) (same 2 forms repeated on many, many sites lawlz, and yes, I looked for every way to get around using target, I swear)

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A doctype declaration can consist of up to four parts:
    1. Root element name
    2. Public identifier
    3. System identifier
    4. Internal subset


    The root element name specifies the document element and is always html for (X)HTML.

    The public identifier, preceded by the keyword PUBLIC specifies the DTD. It must appear exactly as the registered name (no extra spaces or anything).

    The system identifier is really redundant if you have a public identifier, since it's just another way to specify the DTD. Nowadays browsers look for it, though, to determine the parse mode (standards, almost standards or quirks). It should be one of those specified in W3C's list, though (i.e., loose.dtd, not transitional.dtd, which looks like something you may have copied from an XHTML doctype declaration).

    If you have a system identifer without a public identifier, it must be preceded by the keyword SYSTEM.

    The internal subset is enclosed in square brackets and can contain additional, document-specific declarations. Modern browsers don't handle those too well and they aren't very useful for HTML.
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Evangelist Karpie's Avatar
    Join Date
    Jul 2007
    Location
    Perth, Australia
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I always use this site for doctype references (I never remember between projects)

    http://www.webstandards.org/learn/re...ates/html401t/

    Change the last part of the URL as appropriate. And it would seem that yes, there is no actual transitional.dtd.

    The validator should have picked up that you had an invalid doctype. Was this the official W3C validator?

  4. #4
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,276
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    I'm so very super surprised the validator doesn't take a s*** on my doctype-- it SHOULD if it's wrong.

    Quote Originally Posted by tommy
    (i.e., loose.dtd, not transitional.dtd, which looks like something you may have copied from an XHTML doctype declaration).
    Now that's a possibility, though I've never used anything other than strict with my fake XHTML pages... but that's gotta be where I got "transitional.dtd".

    Webstandards.org is where I first went to get my forms better : ) It's a nice site.

    Thanks everyone.

  5. #5
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stomme poes View Post
    I'm so very super surprised the validator doesn't take a s*** on my doctype-- it SHOULD if it's wrong.
    It appears to be a bug in validator.w3.org that it allows arbitrary whitespace in the FPI. There are also other ways you can modify the doctype and still validate, though it's arguable whether that's a bug or broken by design (i.e. following SGML rules).

    http://validator.nu/ will tell you if you get the doctype wrong in text/html. (It doesn't look at the doctype for XML.)
    Simon Pieters

  6. #6
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,276
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Whoa, that validator rocks!! I'd heard something about the encoding should be coming first thing but was never told by a valitator:
    Error: The internal character encoding declaration must be the first child of the head element.

    It called my trasitional.dtd a "legacy doctype". Meaning it caught that space : )

    Not sure about this one:
    Error: Bad value content-language for attribute http-equiv on element meta.
    <meta http-equiv="content-language" content="nl">
    I was told somewhere that some screen readers use the meta tag rather than the lang attribute of the html tag to know what language to go on. And I saw the example as http-equiv (which I thought meant it would normally go in the HTTP Header) so it must be that I can have that meta but not as http-equiv. It didn't like the "Content-Script-Type" one either : )

    Then I got some strange errors. I was pretty sure size was still allowed even in the strict HTML4 doctype, but
    Error: Attribute size not allowed on element input at this point.
    <input type="text" id="Voorvoegsel" name="Voorvoegsel" size="6">

    Element-specific attributes for element input:
    accept
    action
    alt
    autocomplete
    autofocus
    checked
    disabled
    enctype
    form
    list
    max
    maxlength
    method
    min
    name
    pattern
    readonly
    required
    size!!!!!!!!!!!!!?????????????/Here it is???????
    src
    step
    target
    type
    value
    So it's in the list, not sure what's wrong with it. Would I rather use CSS? I would, if it were consistant cross-browser and cross-OS. But FF in Linux makes them way longer than other browsers, and still have trouble with sizing in some others.

    It also caught my labels whose for attributes weren't directly referring to a forrm control (in these older forms I have wrapping divs with the id, and then series of inputs-- my newer forms have fieldsets and hidden labels instead, which follows the rules better).

    Very nice!

  7. #7
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stomme poes View Post
    Whoa, that validator rocks!! I'd heard something about the encoding should be coming first thing but was never told by a valitator:
    Error: The internal character encoding declaration must be the first child of the head element.

    It called my trasitional.dtd a "legacy doctype". Meaning it caught that space : )
    What happened was that since it didn't recognize your doctype, it validated your document as HTML5.

    Quote Originally Posted by Stomme poes View Post
    Not sure about this one:
    Error: Bad value content-language for attribute http-equiv on element meta.
    <meta http-equiv="content-language" content="nl">
    I was told somewhere that some screen readers use the meta tag rather than the lang attribute of the html tag to know what language to go on. And I saw the example as http-equiv (which I thought meant it would normally go in the HTTP Header) so it must be that I can have that meta but not as http-equiv. It didn't like the "Content-Script-Type" one either : )
    Content-Language was recently added to HTML5 -- it's not implemented yet in Validator.nu.

    Quote Originally Posted by Stomme poes View Post
    Then I got some strange errors. I was pretty sure size was still allowed even in the strict HTML4 doctype, but
    Error: Attribute size not allowed on element input at this point.
    <input type="text" id="Voorvoegsel" name="Voorvoegsel" size="6">

    Element-specific attributes for element input:
    accept
    action
    alt
    autocomplete
    autofocus
    checked
    disabled
    enctype
    form
    list
    max
    maxlength
    method
    min
    name
    pattern
    readonly
    required
    size!!!!!!!!!!!!!?????????????/Here it is???????
    src
    step
    target
    type
    value
    So it's in the list, not sure what's wrong with it.
    Same here -- size was just recently added to HTML5. (The list in the user interface is scraped directly from the spec, which is why it's listed there.)

    Quote Originally Posted by Stomme poes View Post
    It also caught my labels whose for attributes weren't directly referring to a forrm control (in these older forms I have wrapping divs with the id, and then series of inputs-- my newer forms have fieldsets and hidden labels instead, which follows the rules better).

    Very nice!
    Simon Pieters

  8. #8
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,276
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    I just sent a (fake) XHTML page... apparently it's doing HTML5 with that as well, possibly because it's sent as text/html.

    Still, pretty cool.

  9. #9
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stomme poes View Post
    I just sent a (fake) XHTML page... apparently it's doing HTML5 with that as well, possibly because it's sent as text/html.
    When I try with an XHTML 1.0 Strict doctype as text/html, it says:
    Info: XHTML 1.0 Strict doctype seen. Appendix C is not supported. Proceeding anyway for your convenience. The parser is still an HTML parser, so namespace processing is not performed and xml:* attributes are not supported. Using the schema for HTML 4.01 Strict + IRI / XHTML 1.0 Strict + IRI.
    So it uses the HTML5 parser and the HTML4/XHTML1 Strict schema.

    BTW, if you want to validate it as XHTML 1.0 (but send it as text/html), you can select the appropriate preset and choose the XML parser and check the "Be lax about HTTP Content-Type" checkbox.
    Simon Pieters


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
  •