Skip to main content

HTML Elements

By SamK
0
0 recommends
Topic(s)

An HTML page is built by the combination of individual HTML elements. 

Each element is defined by a start tag and a corresponding end tag, which comes after the content. 

For example, in case of a paragraph:

<p>Title goes here</p>

The only difference between the start and the end tag is that the end tag contains a preceding slash "/".

Empty Elements

Some elements do not have an end tag like the <br> element. These are called empty elements.

Nested Elements

HTML elements can be nested. That is, an HTML element can contain other HTML elements. In the below example, the <body> element contains two <div> elements and then each <div> element contains two more elements, which are <h1> and <p> elements.

<body>
    <div>
        <h2>This is a heading</h2>
        <p>This is a paragraph</p>
    </div>
    <div>
        <h2>This is a heading</h2>
        <p>This is a paragraph</p>
    </div>
</body>

 Almost all web pages contain nested elements. 

When writing HTML code, make sure that you never skip the end tag because it may cause errors and layout issues.

HTML is not case sensitive and hence HTML tags are not case sensitive as well. But, W3C recommends lowercase in HTML, and demands lowercase for stricter document types like XHTML, so we always use lowercase when writing HTML tags.