Multiple in same file

An HTML document can only have one html tag and one body tag. If you just put several HTML document together, it will be an invalid document, and the browsers may have problems displaying it.

You could remove the duplicate tags, but it might not be that simple. The document can also have only one head tag, so you would have to combine the contents from the head tags from the separate pages. If the pages contains style sheets that conflict, it will be harder, then you have to rewrite the style sheets and it’s usage in the pages so that they no longer conflict. The same goes for Javascript; if you have scripts with conflicting names, you have to rewrite them so that they no longer conflict.

There may be content in the pages that conflict also. An id may only be defined once in a page, so if the pages uses the same identifiers, you have to change them, and their usage in style sheets and scripts.

If you make sure that there are not such conflicts, you should be able to combine the pages.

If you have documents where you only have control over the body content, you can circumvent this by adding starting and ending tags for comments, so that the ending of one file and start of the next file are ignored. That way you can keep the start of the first file, the content from each file, and the ending of the last file:

<html>
  <body>
  content...
  <!--
  </body>
</html>

<html>
  <body>
  -->
  content...
  <!--
  </body>
</html>

<html>
  <body>
  -->
  content...
  </body>
</html>

(Note that this will only use the head section from the first page, the others will be ignored.)

Leave a Comment