HTML - Document


An HTML document 1) is a well-formed HTML string (ie that contains the html root element).

As from one document with Javascript, you can show different text, a web page is a logical representation of a document


The HTML textual representation can be stored:

When the browser process this page, it will create an in-memory/code representation and the HTML page becomes a DOM document.


The URL associated with a Document is the document's address.


Elements represent things; that is, they have intrinsic meaning, also known as semantics. For example, an img element represents an image.


<!-- tells the browser what language it's reading -->
<!DOCTYPE html>
<!-- Starts the HTML document -->
  <title>Sample page</title>
  <h1>Sample page</h1>
  <p>This is a <a href="demo.html">simple</a> sample.</p>
  <!-- this is a comment -->
<!-- Ends the HTML document -->

There are always two parts to the file:

  • the head: The head includes metadata information about the web page, such as its title.
  • and the body. The content in the body is what will be visible on the actual page.



To display a page, a browser:

  • fetches the HTML document over the network (generally with a Http get request)
  • parses the HTML,
  • and then converts it into a code / in-memory representation called a DOM document: (Document Object Model: A tree of nodes)

This is described in details in this page: Web - Timeline of a page load (Page Speed|Page Latency)



The identifier of a HTML document is its URL.

But because you may render or move a HTML page to another URL, the rel=canonical was introduced to represent an universal id (as described in RFC 6596).

And to complicate things, all metadata schema may also have their own meta where to store this information. For instance, og:url for the open graph tag


On Facebook, If you move a page to a new URL, you can use the old URL as the canonical source for the new URL, retaining likes, comments and shares for the object. Ref Ref2 - How do I move a page to a different URL?

Html document inside Html document

Note that a html document can contain other document with the frame, iframe.

Powered by ComboStrap