• stuff
  • Attributes in closing element tags?

    Is it valid to do the following:

    <li>stuff</li class="randomlengthclassname"> <li>stuff</li class="shortclassname"> <li>stuff</li class="reallyreallylongarseclassname"> 

    or does the attribute have in the opening tag?

    +4
    source share
    5 answers

    No, it is not. You must use the attributes in the opening tag.

    Running <a>test</a href="tst.html"> in the w3c validator results in this error:

    Invalid name start character: only S delimiters and TAGC are allowed

    Where s separators and tagc:

      S is "whitespace" separator [5] s = SPACE | (32) space RE | (13) CR RS | (10) LF SEPCHAR (9) HT -- http://xml.coverpages.org/sgmlsyn/sgmlsyn.htm#C6.2.1 TAGC ">" -- http://www.w3.org/TR/sgml.l 
    +9
    source

    It is not , and all attributes must be defined in the opening tag.

    +5
    source

    The attribute must be in the opening tag. The code you submitted will probably not work.

    +2
    source

    Attributes should appear in the start tag of the element. W3C citation : on SGML and HTML attributes :

    ... Attribute / value batches appear before the final ">" of the element's initial tag. In the element’s start tag, any number of (pair) attribute pairs may appear, separated by spaces. They can appear in any order.

    +2
    source

    Closing tags may not contain attributes. But in HTML4 you can omit LI closure:

     <!ELEMENT LI - O (%flow;)* -- list item --> <!ATTLIST LI %attrs; -- %coreattrs, %i18n, %events -- > Start tag: required, End tag: optional 

    In XHTML you cannot.

    0
    source

    All Articles