HTML Elements
Example: In this example <p> is a starting tag, </p> is an ending tag and it contains some content between them. The combination of starting tag, some content, and ending tag is an element. So, <p>Hi Geeks!</p> is an element. Similarly <h2>Welcome To GeeksforGeeks</h2> is an another element.
HTML
<!DOCTYPE html><html> <body> <h2>Welcome To GeeksforGeeks</h2> <p>Hi Geeks!</p> </body> </html> |
Output:

HTML element is the collection of start and end tag with the content inserted in between them.
Supported Tags: HTML Elements supports almost all HTML Tags.
Syntax:
<tagname > Contents... </tagname>
Example:
HTML
<!-- HTML code to illustrate HTML elements --><!DOCTYPE html><html> <head> <title>HTML Elements</title></head> <body> <p>Welcome to GeeksforGeeks!</p> </body> </html> |
Output:
Welcome to GeeksforGeeks!
Nested HTML Elements: The HTML element is use inside the another HTML Element is called nested HTML elements.
Example:
HTML
<!DOCTYPE html><html> <head> <title>HTML Elements</title></head> <body style="text-align: center"> <h1>GeeksforGeeks</h1> <p>Computer science portal</p> </body> </html> |
Output: In this example, <html> tag contains the <head> and <body>. The <head> and <body> tag contains another elements so it is called nested element.

Necessary to add end tag: It is necessary to add end tag of element. Otherwise, the displayed content may or may not be displayed correctly.
Example:
HTML
<!DOCTYPE html><html> <head> <title>HTML Elements</title></head> <body> <!-- h1 tag does not contains end tag --> <h1>GeeksforGeeks</h1> <!-- p tag does not contains end tag --> <p>Computer science portal</p> </body> </html> |
Example:

Empty HTML Elements: HTML Elements without any content i.e, that do not print anything are called Empty elements. Empty HTML elements do not have an ending tag.
For Ex. <br>, <hr>, <link>, <input> etc are HTML elements
Example:
HTML
<!DOCTYPE html><html> <head> <title>Empty HTML Elements</title></head> <body> <h2>Welcome To GfG</h2> <br /> <p>Hello Geeks.</p> </body> </html> |
Output: In this example <br> tag doesn’t print anything. It is used as a breakline that breaks the line between <h2> and <p> tag.

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML course.


