tags:

views:

2185

answers:

3

Will this validate in XHTML?

<span>hello<span>world</span></span>
A: 

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

dusoft
+11  A: 

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"&gt;
      <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>
RichardOD
That will answer the "validate" part of the question, but not the "OK" part. The DTD can only describe a subset of the specification.
David Dorward
thanks. i didn't know about the direct input option!
rick
+12  A: 

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.

joebert