HTML Elements:

An HTML document has various elements; elements are used as they contain the text or the document which shows that this document is an HTML document. An HTML document starts with <html>, which is an element indicating that the following text is HTML type. An HTML document can be differentiated from a simple document using elements; these elements contain head, title, tags, and body of the document.

Spaces Inside Elements

HTML becomes sensitive regarding spaces, when we give a space between a tag and the content related to the tag, this space is considered as a white-space which may change the justification for a specific content or item. Therefore, it is recommended not to give space between tags and contents. This is illustrated below:


<p2> Paragraph2

Both of the statements are opposite to each other. A problem may arise when you are formatting your document. It is always safest not to generate unnecessary spaces between a tag and the enclosed text.


The Document Body

After the heading there comes the body of the document, this also contains paragraphs and sub paragraphs. This element of HTML contains all contents or texts that are displayed in the document. The body of the document is demonstrated below:



<title> This is the tile </title>



<h1> This is the heading </h1>

<p>  this is the first paragraph  </p>



It is quite clear from the above example that the body of the document contains heading and paragraphs. The tag for the body is <body>, like other tags this has also an ending tag </body> which shows that the body of the tag is closed. This concept is the same as that of the closing bracket. An HTML document is designed to give your text or document a logical look.


The HTML document also supports some lists. There are two types of lists in HTML document that are; unordered list, and ordered list. Every list must be ended with an end tag, for unordered list, we use <UL> tag and the ending tag is </UL>, for ordered list, we use <OL> tag and the ending tag is </OL>. A list can never be empty. The UL and OL contain list item elements. A list item element starts with a tag <L1> and the ending tag is </L1> but the ending tag is not necessary.

We can define an unordered list of elements as the lists that does not numbers or letters.A list <L1> element can have text, images, other lists, and paragraphs.


<L1> ordered list items



After saving this document with the html extension and encoding as Unicode, the following will appear on the browser.




Empty Elements

In an HTML document there are some elements that can be kept empty; these include IMG, HR etc. There is another element that can also be kept empty this is BR which indicates line break. These tags do not need end tags. But formally you can do this.

Element Nesting

In an HTML document all the elements have some restrictions of what can be nested in between them and also where these elements can be nested.