i

Learn HTML and CSS in 10 Days

Creating HTML Document Structure

Plain text document that has a .html extension (not .txt) are known as an HTML document. To start writing the HTML code, one needs to have a text editor with which the individual is comfortable. Unfortunately, this does exclude Microsoft Word. For writing HTML and CSS codes, 2 of the most popular ones are Sublime and Dreamweaver. Free options likewise incorporateTextWrangler for Mac and Notepad++ for Windows.

Every HTML documents consists of the below mentioned elements and declaration

The or the Document Type declaration is kept at the start of the HTML document. Its main function is to make the web browsers accustomed with the HTML version. After the Document Type declaration comes the element which marks the start of the document.

The top of the document is identified by  element which is placed inside the  element. The head contains the metadata (accompanying data regarding the page). Contents that are located inside the  element is not shown on the web page. Apart from that, the  element consists of links to any outside documents, the element which contains the title of the document (the name that is shown on the title bar of your browser), etc.

Contents that you can see on the web page is written inside the  element. Have a look at the code below to get a clearer picture of the things described above.


The above code says the web browser about the start of the document by  (document type declaration), succeeded by element. The and the

elements are enclosed inside the element. The  element consist of   tag, character encoding of the web page, and the , the title of the document which appears in the title bar. Now inside the body element there are 2 things i.e.  and is used for headings and  is used for paragraph. As both the elements are present within the body element, they are appeared on the web page.

When an element is placed within another element, it is called a nested element. It is a smart thought to indent that component to keep the document structure efficient and decipherable. Thus looking through the above code we can say that  and  element are the nested element present inside the  element. The method of indenting elements proceeds as new elements are included within the  and  components.

Self-Closing Elements

We hope that you have noticed one thing a bit different in the above code. Except for the element, all tags consisted of a closing tag. Don't worry; we have not done it intentionally. We just wanted to conclude that not every element which you are going to come through in HTML need to have an opening and a closing tag. Some elements are okay with a single tag, and the is categorized as one of them. Some other examples of self-closing elements are as follows:-