Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attributes in elements closing tag?

Is it considered valid to do the following:

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

or do the attribute have to be in the opening tag?

like image 550
Hailwood Avatar asked Dec 02 '22 04:12

Hailwood


2 Answers

No it isn't. You must use attributes in the opening tag.

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

name start character invalid: only S separators and TAGC allowed here

Where S separators and TAGC are:

    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
like image 71
Oded Avatar answered Dec 04 '22 16:12

Oded


This is not valid, and all attributes must be defined in the opening tag, indeed.

like image 24
Romain Linsolas Avatar answered Dec 04 '22 16:12

Romain Linsolas