HOME C C++ PYTHON JAVA HTML CSS JAVASCRIPT BOOTSTRAP JQUERY REACT PHP SQL AJAX JSON DATA SCIENCE AI

HTML Elements

An HTML element is the building block of any web page. It's like a mini-container that defines the structure and content of your website. Think of it like a Lego piece; you combine different elements to create the entire website.

Start tag content End tag
<h1> This is heading content. </h1>
<p> This is paragraph content. </p>
</br>

So here <p>....</p> is an HTML element, <h1>...</h1> is another HTML element. There are some HTML elements which don't need to be closed, such as </img>, </hr> and </br> elements. These are known as void elements.

Nested HTML Elements

Nested HTML elements refer to the ability of one HTML element to contain other HTML elements within its opening and closing tags. This hierarchical structure is fundamental to building the content and layout of web pages.

Example

    
    <!DOCTYPE html>
    <html>
    <head>
    <title>Nested Elements</title>
    </head>
    <body>
    <h1>This is <i>italic</i> heading</h1>
    <p>This is <u>underlined</u> paragraph</p>
    </body>
    </html>
 
You can click on above box to edit the code and run again.

Output

This is italic heading

This is underlined paragraph

Empty HTML Elements

HTML elements with no content are called empty elements.

The <br> tag defines a line break, and is an empty element without a closing tag:

Example

    
<p>This is a <br> paragraph with a line break.</p>
                

You can click on above box to edit the code and run again.

Output

This is a
paragraph with a line break.