HTML Elements

4 min read ·

An HTML element is the fundamental building block of an HTML document.
An element usually consists of
  1. A start tag
  2. Content
  3. An end tag
The browser reads elements to understand how content should be structured and displayed.

Basic Structure of an HTML Element

An HTML element is written using angle brackets.
In this example <p> is the start tag This is a paragraph is the content </p> is the end tag
Together they form one complete HTML element.

Parts of an HTML Element

PartDescription
Start tagMarks the beginning of the element
ContentText or nested elements inside
End tagMarks the end of the element
Not all elements contain all three parts.

Nested HTML Elements

HTML elements can contain other elements inside them.
This is called nesting.
Here <h2> and <p> are nested inside <div>
Proper nesting is required for correct page structure.

HTML Empty Elements

Some HTML elements do not have closing tags.
These are called empty elements.
Empty elements do not contain content.

Common Empty Elements

ElementPurpose
<br>Line break
<img>Displays an image
<hr>Horizontal line
<input>User input field
Empty elements rely entirely on attributes.

Block Level Elements

Block level elements start on a new line.
They take up the full available width by default.

Common Block Level Elements

ElementDescription
<div>Generic container
<p>Paragraph
<h1> to <h6>Headings
<section>Page section
<article>Independent content
Block elements are used for layout and structure.

Inline Elements

Inline elements do not start on a new line.
They take only as much width as needed.

Common Inline Elements

ElementDescription
<span>Inline container
<a>Link
<strong>Strong importance
<em>Emphasized text
<img>Inline image
Inline elements are used inside block elements.

HTML Elements With Attributes

Elements can include attributes that provide additional information.
Here href is an attribute It defines the link destination
Attributes are written inside the start tag.

HTML Is Case Insensitive

HTML tags are not case sensitive.
Both are valid.
However lowercase tags are recommended for readability and consistency.

Correct and Incorrect HTML Elements

Correct structure
Incorrect structure
Improper nesting can cause layout and rendering issues.

Browser Interpretation of Elements

Browsers do not display HTML tags.
They interpret elements and render content visually.
Different elements have predefined display behavior.

Why Understanding HTML Elements Is Important

HTML elements define Page structure Content meaning Accessibility Search engine understanding
A strong understanding of HTML elements is essential before learning styling and scripting.

Practice Example

This example uses Block elements Inline elements Empty elements Attributes

HTML elements form the backbone of every web page.
Mastering elements is a critical step toward professional web development.