Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are nested span tags OK in XHTML?

Tags:

html

xhtml

Yes it will. You can help yourself by using the w3's validator direct input option:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
        <head>
          <title>Title</title>
        </head>

        <body>
           <p>
               <span>Test<span>Nest span</span></span>
           </p>
        </body>
      </html>

Absolutely.

Here's the definition from an XHTML-strict DOCTYPE for a span element.

<!ELEMENT span %Inline;> <!-- generic language/style container -->
<!ATTLIST span
  %attrs;
  >

The "%Inline" part tells me that it can have child nodes from the "% Inline;" entities element list.

The span element is included in the list of elements classed as "% Inline", that combined with span allowing "%Inline" child elements tells me that span is a valid child of span.


SPAN can contain only inline elements, such as SPAN etc.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!