HTML Elements

HTML Elements are the building blocks of every web page.
Each element defines a part of the webpage, such as headings, paragraphs, links, or images.

In this tutorial, you will learn what HTML elements are, their structure, and see examples with output.

What Are HTML Elements

An HTML element is a complete unit of HTML code that includes:

  • Opening tag
  • Content
  • Closing tag

HTML elements define how content is structured on a webpage.


Structure of an HTML Element

Example

<p>This is a paragraph</p>

Explanation

PartDescription
<p>Opening tag
ContentText inside the tag
</p>Closing tag

HTML Element Example with Output

Example Code

<h1>HTML Elements</h1>
<p>This is a simple example of an HTML element.</p>

Output

HTML Elements
This is a simple example of an HTML element.


Types of HTML Elements

HTML elements are mainly divided into two types.

Types of Elements

TypeDescription
Container ElementsHave opening and closing tags
Empty ElementsDo not have closing tags

Container Elements

Container elements contain content between opening and closing tags.

Example

<p>This is a container element.</p>

Output

This is a container element.


Empty Elements

Empty elements do not have closing tags.

Example

<br>
<hr>

Explanation

  • <br> creates a line break
  • <hr> creates a horizontal line

Output

Line 1
Line 2



Nested HTML Elements

HTML elements can be placed inside other elements. This is called nesting.

Example Code

<p>This is a <b>bold</b> word.</p>

Explanation

  • <b> is inside <p>
  • This creates bold text inside a paragraph

Output

This is a bold word.


HTML Elements Can Be Nested Multiple Times

Example

<p>This is <i>italic and <b>bold</b></i> text.</p>

Output

This is italic and bold text.


HTML Elements Summary Table

FeatureDescription
StructureOpening + Content + Closing
TypesContainer and Empty
NestingElements inside elements
Case SensitiveNo (but use lowercase)

Block vs Inline Elements (Introduction)

HTML elements are also categorized as:

TypeDescription
Block ElementsTake full width
Inline ElementsTake only required width

Example

<p>This is a block element</p>
<span>This is inline</span>

Output

This is a block element
This is inline


Common HTML Elements

ElementPurpose
<h1>Heading
<p>Paragraph
<a>Link
<img>Image
<br>Line break

Rules for HTML Elements

RuleDescription
Proper ClosingClose tags correctly
Correct NestingDo not overlap tags
Lowercase UsageBest practice
Use StructureFollow proper format

Common Mistakes with HTML Elements

MistakeProblem
Missing closing tagLayout issues
Wrong nestingBroken HTML
Using uppercaseNot recommended
Empty content misuseNo visible output

HTML elements, HTML element examples, HTML tags vs elements, HTML basics, learn HTML elements


Frequently Asked Questions (FAQ)

1. What is an HTML element?

An HTML element is a complete unit with opening tag, content, and closing tag.

2. What is the difference between tag and element?

A tag is part of an element, while an element is the complete structure.

3. What are empty elements?

Elements without closing tags.

4. Can HTML elements be nested?

Yes, elements can be placed inside other elements.

5. Are HTML elements case-sensitive?

No, but lowercase is recommended.

Related Article
Introduction to HTML

HTML Introduction – Learn the Basics of HTML HTML is the starting point of web development. Every website you see Read more

What is HTML

What Is HTML – Complete Beginner Explanation HTML is the foundation of the web. Every website you visit, from simple Read more

HTML Basic Examples

HTML Basic Examples – Learn HTML by Practice The best way to learn HTML is by writing and testing simple Read more

HTML text Editors

HTML Text Editors – Learn How to Write HTML Code To write HTML code, you need a text editor. A Read more

HTML Tags

HTML Tags are the basic units used to create HTML elements.They define how content is displayed in a web browser. Read more

HTML Attributes

HTML Attributes provide additional information about HTML elements.They help control how elements behave, display, or store extra data. In this Read more

HTML Headings

HTML Headings are used to define titles and subtitles on a web page.They help organize content and improve readability for Read more

HTML Paragraphs

HTML Paragraphs are used to display blocks of text on a web page.They help organize content into readable sections. In Read more