2

Is this valid HTML?

<!DOCTYPE html>
<html>
    <head/>
    <body>
        <p>Hello, World</p>
        <html>
            <head/>
            <body>
                <p>Hello, World 2: Revenge of the Pointer</p>
            </body>
        </html>
        <html>
            <head/>
            <body>
                <p>Hello, World 3: GOTO null</p>
            </body>
        </html>
    </body>
</html>

According to the HTML5 specs, the <html> element can be used:

  • As the root element of a document.
  • Wherever a subdocument fragment is allowed in a compound document.

It's the second part that I'm confused about. Does this mean that <html> is a "document" and any nested <html> is a "subdocument fragment"? How can I tell if this is "allowed"?

Scribblemacher
  • 1,518
  • 1
  • 16
  • 31
  • In html5 it **is** valid but it also is **bad practice**. Why would you want to repeat `html`-elements? In your situation, why not use `article` and `section` elements? Just looked a bit further: allthough it is in the specifications, browsers dont seem to like it. – Jordumus Sep 04 '15 at 13:28
  • Doesn't seem to validate and your head tags are incorrect. – j08691 Sep 04 '15 at 13:29
  • 1
    Possible duplicate of [Multiple in same file](https://stackoverflow.com/questions/2035462/multiple-htmlbody-html-body-in-same-file) – Kukeltje Nov 07 '19 at 09:19

2 Answers2

3

As said by Guffa

A compound document is a document in itself and you can't use html to make a sub-document.

But a html may contain a iframe which is a sub-document and has html tag. enter image description here

Golden_flash
  • 492
  • 1
  • 6
  • 14
2

No, that is not valid.

A compound document has a subdocument fragment declared inside it, which is a complete document in itself. You can't just use another html tag to make a compound document.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005