HTML Element Syntax

There are three types of HTML elements:

An empty element has no content, only attributes. Its format is:

   <tag attribute1="value1".../>

Where values are strings.


The format of a non-empty element is:


   <tag attribute1="value1"...> content </tag>

Where content can be a mixture of other HTML elements depending on the tag. This means we can view the structure of an HTML document as a tree, where elements are nodes, and element A is a child of element B if A occurs in the content of B.

The root of the tree is the html element:


   <html>
      <head>
         meta data goes here
      </head>
      <body>
         body elements go here
      </body>
   </html>