An HTML element is defined by a start tag, some content, and an end tag. The element is everything from the opening tag through the closing tag.
Start tag, content, end tag
Write <tagname>, put content in the middle, then close with </tagname>. Example: <p>A paragraph.</p> is one paragraph element.
What are nested elements?
Elements can contain other elements. Every HTML page is a nested tree: the <html> root wraps <body>, which wraps headings, paragraphs, and more.
When are elements empty?
Some elements have no content and no end tag—for example <br> (line break) and <img> (image). These are called empty or void elements.
Tag vs element.
A tag is the bracketed name (<p>). An element is the full unit: tags plus content (or a single empty tag).
Never skip the end tag.
Browsers may still display a page if you omit </p>, but results can be wrong. Always close normal elements.
Lowercase is recommended.
HTML is not case-sensitive (<P> works), but write lowercase tags—it matches modern style and XHTML rules.
Syntax
HTML Element Syntax
The basic form of a normal element:
element.html
<tagname>Content goes here… </tagname>
HTML
<h1>A Heading</h1>
<p>A paragraph.</p>
<!-- Empty element: no content, no end tag -->
<br>
<!-- Attribute in the start tag -->
<a href="https://example.com">Visit Example</a>
Start tag
Element content
End tag
<h1>
A Heading
</h1>
<p>
A paragraph.
</p>
<br>
none
none
Attributes live only in the start tag: name="value". Empty elements never get an end tag.
Reference
Core HTML Concepts
Ideas that keep markup valid and readable:
Concept
Meaning
Start + content + end
Normal element shape: <p>…</p>
Empty / void
No content, no end tag (<br>, <img>)
Nesting
Elements inside elements; close inner first
Attributes
Extra info in the start tag (href, src, id)
Root document
<html> wraps the whole page
Body content
Visible page content lives inside <body>
Lowercase
Recommended style for tag names
Tag vs element vs attribute
Tag
Element
Attribute
What it is
Markup markers like <p>
Full unit including content
Name/value in the start tag
Example
<a> / </a>
<a href="…">Go</a>
href="…"
Visible?
Not as text
Content usually is
Not shown as page text
Approach
How to Write HTML Elements
Practical habits for clean markup.
Pick the right tag for meaning (<h1> for a main heading, <p> for a paragraph).
Always write matching start and end tags for normal elements.
Nest cleanly: open outer, open inner, close inner, close outer.
Use empty tags only where content is not allowed (<br>, <img>, <hr>).
Put attributes in the start tag with quoted values.
Prefer lowercase tag and attribute names.
Goal
Pattern
Heading
<h1>Title</h1>
Paragraph
<p>Text</p>
Line break
<br>
Nesting
<p>Hi <strong>you</strong></p>
Attribute
<a href="url">Link</a>
Try it
Live Preview
Switch between a basic element, nested markup, an empty line break, and an attribute example.
Shows rendered output next to the source shape of each element pattern.
Rendered page
A paragraph.
<p>A paragraph.</p>
Code
HTML Examples
Six patterns: basic syntax, nesting explained, empty elements, closing tags, attributes, and a full page.
br inserts a line break with no content and no end tag.
hr draws a thematic break—also empty.
img embeds an image; src and alt are attributes.
Never write</br> or </img>.
Example 4 — Always Close Normal Elements
HTML
<!-- Good: end tags present -->
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<!-- Risky: missing end tags (do not rely on this) -->
<!--
<p>This is a paragraph
<p>This is a paragraph
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML Elements Example</title>
</head>
<body>
<h1>Welcome to My Website</h1>
<p>This page is built from nested HTML elements.</p>
<p>Here is a line break:<br>second line.</p>
<p>Visit <a href="https://www.codetofun.com">CodeToFun</a>.</p>
</body>
</html>
Most element bugs come from missing end tags, crossed nesting, or treating void tags like normal ones.
close
Missing end tags
Browsers may auto-close, but nested content can attach to the wrong parent.
nest
Crossed nesting
Do not write <p><strong>x</p></strong>. Close in reverse order.
void
End tags on empty elements
</br> or </img> is invalid. Use only the start tag.
attr
Attributes on the end tag
Attributes belong only in the start tag, never in </p>.
case
Mixed-case tag soup
<P> works in HTML, but stick to lowercase for consistency and tooling.
p
Block inside paragraph
A <p> cannot contain another <p> or headings—the browser will split it.
Compatibility
Browser Support
HTML elements (start tags, content, end tags, and void elements) are core HTML and work in all browsers.
✓ Baseline · Widely available
HTML elements
Every browser that parses HTML understands elements, nesting, and empty tags.
100%element syntax
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
HTML elementsUniversal
Bottom line: Write well-formed elements with matching tags—browsers everywhere will render them.
Remember
Key Takeaways
Start + content + end defines a normal HTML element.
Empty elements like <br> and <img> have no end tag.
Nesting builds the whole document tree—close inner tags first.
Attributes add name/value data inside the start tag only.
One line: An HTML element is <tag>content</tag> (or a single empty tag), and pages are trees of nested elements with optional attributes on start tags.
Frequently Asked Questions
An HTML element is everything from a start tag through its content to the matching end tag—for example <p>Hello</p>. The element is the whole unit, not just the tags.
A tag is the markup piece such as <p> or </p>. An element is the complete unit: start tag, content, and end tag—or a single empty tag like <br> or <img>.
Empty elements have no content and no end tag. Common examples are <br>, <hr>, <img>, <meta>, and <input>. You write only the start tag (a trailing slash is optional in HTML).
Yes. Elements can contain other elements. All HTML documents are nested trees: html wraps body, body wraps headings and paragraphs, and so on. Close inner tags before outer ones.
For normal elements, always write the end tag. Browsers may guess when it is missing, but that leads to bugs. Empty elements never take an end tag.
Attributes add extra information in the start tag, usually as name="value" pairs—for example <a href="https://example.com">. They customize how the element behaves or is identified.