¿Están bien las etiquetas span anidadas en XHTML?


¿Se validará esto en XHTML?

<span>hello<span>world</span></span>
 138
Author: rick, 2009-07-03

3 answers

Sí lo hará. Puedes ayudarte usando la opción de entrada directa del validador de w3 :

<!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>
 134
Author: RichardOD,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-07-03 07:33:26

Absolutamente.

Aquí está la definición de un DOCTYPE XHTML-strict para un elemento span.

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

La parte "%Inline" me dice que puede tener nodos hijos de la lista de elementos de entidades "% Inline;".

El elemento span está incluido en la lista de elementos clasificados como "% Inline", que combinado con span permitiendo elementos secundarios "%Inline" me dice que span es un hijo válido de span.

 84
Author: joebert,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-07-03 07:38:02

SPAN solo puede contener elementos en línea, como SPAN, etc.

 27
Author: dusoft,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-07-03 07:14:15