XHTML Strict validation something it shouldn't?

Discussion in 'HTML & Website Design' started by Stomme poes, Mar 2, 2008.

  1. #1
    O Bikkhus,

    I was reworking a page for fun and asked the owner why there were some invalid things sitting in the code? And he was like, the only invalid thing is the "target" attricbute. And I was like, what about this?

    <a name="messages" />

    And he was like, that's valid. And I was like, what? A isn't an "empty" tag, and "name" was deprecated for <a>, so wtf? And he was like, *shrug* I dunno but the validator from W3C says it's fine.

    So I check it and yup, the only thing if complains about is target attribute (which is getting removed when the rewrite is over, no worries there).

    So the question is, wtf??? How is this allowed through the validator? It's not valid!

    PS the purpose of this piece of code was apparently to use it for inter-page skip links. I guess it was working as such on all browsers, too. Wery strenge.
     
    Stomme poes, Mar 2, 2008 IP
  2. Morishani

    Morishani Peon

    Messages:
    239
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Check the validator options/parameters.
     
    Morishani, Mar 2, 2008 IP
  3. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #3
    That's perfectly legitimate, though the syntax is a little iffy. The <a> element is not an empty element and should really have a closing tag rather than a self-closing one. i.e.
    <a name="here"></a>
    Code (markup):
    The name attribute is not deprecated for the anchor element.
    cheers,

    gary
     
    kk5st, Mar 2, 2008 IP
  4. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #4
    But that's from HTML4. I mean this:
    So, if something's formally deprecated, why doesn't the validator catch it? I'm thinking specifically of how I learned that "name" was no longer allowed in Forms: the vlaidator caught it and I was like, whuh? But it was so.

    *Edit this was my fault, I didn't specify that this was an XHTML Strict doctype, and there's also that silly XML prologue-thing in the front too, if that possibly had anything to do with it.
     
    Stomme poes, Mar 2, 2008 IP
  5. jamesicus

    jamesicus Peon

    Messages:
    477
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #5
    URL please, Stomme poes?

    James
     
    jamesicus, Mar 2, 2008 IP
  6. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #6
    To the page itself? http://.iannounce.co.uk/screenshots.html (I dunno how much longer that design will stay online-- the one I'm looking at, in the source, the <a>s are sitting just above the (multiple) h1's). The page should be mostly white and mostly text. I've heard there is a designer involved so if a new page is uploaded I expect there will be some design in it.
    Or where I found the quote? http://www.w3.org/TR/xhtml1/#h-4.10

    I was kinda hoping you'd answer this one James since you seem to be all into this sort of thing.

    I did post this on the other Point too to get some opinions but I was told first that it wasn't deprecated in XHTML 1.0 (I think he must've been confused as there I did state the doctype) and second that because <a / >would be vaild XML it would go through the validator, but I had always thought that I could not get away with <p foo man choo /> for instance plus since browsers don't understand <em/foo/ shouldn't I get a warning at least?
     
    Stomme poes, Mar 2, 2008 IP
  7. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #7
    :oops: Should've guessed you meant xhtml.

    Recheck just how you used the name attribute. It's required on all but two form controls.

    <!ENTITY % InputType
      "(text | password | checkbox |
        radio | submit | reset |
        file | hidden | image | button)"
       >
    
    <!-- the name attribute is required for all but submit & reset -->
    Code (markup):

    Remember that only name/value pairs are returned on submit.

    cheers,

    gary
     
    kk5st, Mar 2, 2008 IP
    Stomme poes likes this.
  8. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #8
    I think he means on the <form> itself, which is indeed invalid.
     
    blueparukia, Mar 2, 2008 IP
  9. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #9
    ^ yup that is what I meant... I rewrote a website which had this:

    <form name="something">
    form form form
    </form>

    Which I originally had kept because my colleague who had written it was using "name" for scripts... but when I went to submit the validator was all like, "Name has been deprecated for this element." So now I wonder why this other guy's site doesn't get that message.

    According to some Crusties on another forum, it's technically still allowed and the funny ending is allowed simply because it's okay in XML even tho an XML parser will never come across this page (and also technically allowed for HTML/SGML but browsers don't understand it anyway). I'm guessing since the a is being written empty, the browser doesn't have to worry about trying to render it since it's the same as
    <div>
    </div>
    which the browser would also ignore.

    As a side note:
    I consider Select as a form control as well (the above w3c quote doesn't mention them). I do usually set a name and id on them for my colleague's scripts, but I never checked if they too must have a name... but this is different topic : )
     
    Stomme poes, Mar 3, 2008 IP
  10. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #10
    "Select" is defined elsewhere. The name attribute is not specifically required for select, but that's the only legitimate way to submit the value.

    Oh, and note that "name" is an attribute of the anchor element, i.e. not deprecated for that element.
    
    <!--================== The Anchor Element ================================-->
    
    <!-- content is %Inline; except that anchors shouldn't be nested -->
    
    <!ELEMENT a %a.content;>
    <!ATTLIST a
      %attrs;
      %focus;
      charset     %Charset;      #IMPLIED
      type        %ContentType;  #IMPLIED
      [color=red]name        NMTOKEN        #IMPLIED[/color]
      href        %URI;          #IMPLIED
      hreflang    %LanguageCode; #IMPLIED
      rel         %LinkTypes;    #IMPLIED
      rev         %LinkTypes;    #IMPLIED
      shape       %Shape;        "rect"
      coords      %Coords;       #IMPLIED
      >
    Code (markup):
    cheers,

    gary
     
    kk5st, Mar 3, 2008 IP
  11. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #11
    ^ not for XHTML?? I realise it's allowed for HTML. But I gots me a quote! (above)
     
    Stomme poes, Mar 3, 2008 IP
  12. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
  13. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Ayup.

    
    <!--================== The Anchor Element ================================-->
    
    <!-- content is %Inline; except that anchors shouldn't be nested -->
    
    <!ELEMENT a %a.content;>
    <!ATTLIST a
      %attrs;
      %focus;
      charset     %Charset;      #IMPLIED
      type        %ContentType;  #IMPLIED
      name        NMTOKEN        #IMPLIED [b]<---- thar she blows[/b]
      href        %URI;          #IMPLIED
      hreflang    %LanguageCode; #IMPLIED
      rel         %LinkTypes;    #IMPLIED
      rev         %LinkTypes;    #IMPLIED
      shape       %Shape;        "rect"
      coords      %Coords;       #IMPLIED
      >
    
    Code (markup):
    Thx Gary. It still looks weird... maybe the author didn't want to do <a name="message"></a> (I've done this without the "name" and learned if I want it to be a block I need a space between the two tags or it collapses on itself).

    I've re-dug back up the HTML4 specpage too and they're both bookmarked, which I should have done in the beginning. Sometimes I think I'm wasting time on HTML forums, but I learn more here than in the books I've bought (tho they were essential in getting me started). Thanks again.
     
    Stomme poes, Mar 3, 2008 IP