In this tutorial, through examples, we will learn about HTML Elements as well as the many available elements and syntax. An HTML element is made up of a set of start and end tags with content put in between.
Syntax:
<tagname>Content</tagname>
HTML components can be nested, which means they can be stacked on top of each other (this means that elements can contain other elements).
Nested HTML elements are present in any HTML elements.
The below example 1 contains five HTML elements (<html>, <body>, <h1>, <h2> and <p>):
Example 1:
<!DOCTYPE html>
<html>
<body>
<h1>Welcome To HTML tutorial</h1>
<h2>Your second heading<h2/>
<p>Hi User !</p>
</body>
</html>
Output :
Example 2: This example illustrates the use of the HTML paragraph element.
<!DOCTYPE html>
<html>
<body>
<h1>Welcome To HTML tutorial</h1>
<p>Hi User !</p>
</body>
</html>
Nested HTML Elements: Nested HTML elements are HTML elements that are used inside another HTML element.
Below example describes the use of the Nested HTML elements. below body tag contains <h1> tag and <p> tag and see <p> is also containing <b> tag. This is called as nested HTML elements.
<!DOCTYPE html>
<html>
<body>
<h1>HTML tutorial</h1>
<p> <b>HTML</b> elements</p>
</body>
</html>
Necessary to add end tag: It is required to include an element's end tag. The provided content may or may not be displayed appropriately if this is not the case.
Example 4: This example describes the HTML element by specifying the end tag.
<!DOCTYPE html>
<html>
<body>
<h1>HTML tutorial</h1>
<p> <b>HTML</b> elements</p>
<button>This is button</button>
<a>Edit</a>
</body>
</html>
Output:
Empty HTML Elements: Empty HTML Elements are HTML elements that have no content and do not print anything. There is no ending tag for empty HTML elements.
Example 5: In this example
<!DOCTYPE html>
<html>
<body>
<p>This paragraph contains <br> a line break.</p>
</body>
</html>
Output:
This paragraph contains
a line break.