Tag in HTML: What It Is, Syntax Rules and Tag List
November 11, 2026 · 14 min read
What Is a Tag in HTML? Elements, Attributes and an HTML Tag List
A tag in HTML is the markup inside angle brackets that marks where an element starts or ends. <p> opens a paragraph and </p> closes it. Browsers read tags to build the page but never display them. Below you'll find the exact anatomy, the syntax rules that trip people up, and a grouped HTML tag list.
What Are Angle Brackets in HTML Tags?
Angle brackets are the < and > characters that wrap every tag. Whatever sits between them is an instruction for the browser, not text for the reader. HTML is a markup language, a family our Markdown vs markup explainer covers in more depth.
A start tag is the element's name in angle brackets. An end tag adds a forward slash before the name. It's a forward slash, not a backslash, whatever some tutorials say.
<p>Hello, world</p>
The browser shows only Hello, world as a paragraph of text. The <p> and </p> vanish from the visible page, though they stay in the source and the DOM holds the p element they create. To show a literal angle bracket as text, write the character reference < for < and > for >.
Tag in HTML, Element or Attribute: What's the Difference?
People use "tag" loosely, but the spec separates three ideas. Tags are the markup. An element is the whole thing the tags create, including its content. Attributes are extra settings written inside the start tag.
<abbr title="HyperText Markup Language" class="term">HTML</abbr>
Here's how that line breaks down:
<abbr title="HyperText Markup Language" class="term">is the start tag.titleandclassare attribute names, and the quoted text after each=is the attribute value.HTMLis the element's content, the only part the reader sees.</abbr>is the end tag.- The start tag, content and end tag together make one
abbrelement.
This is why "alt tag" is a misnomer. alt is an attribute on the img element, not a tag of its own. The same goes for "title tag" when someone means the title attribute, which differs from the <title> element in the page head.
Tags With No Closing Tag: The 13 Void Elements
Most elements take two tags, a start tag and an end tag. Void elements can't hold content, so they get a start tag only. The WHATWG HTML syntax section lists exactly 13 of them.
The void elements are area, base, br, col, embed, hr, img, input, link, meta, source, track and wbr.
<p>Line one<br>Line two</p>
<img src="cat.jpg" alt="A grey cat asleep on a keyboard">
<input type="email" name="email" required>
That renders a paragraph split over two lines, an image (or its alt text if cat.jpg is missing) and an email field. Writing </br> or </img> is an error. Void elements have no content, so there's nothing for an end tag to close.
What about <br />? In HTML the trailing slash on a void element is allowed, but the spec says it's unnecessary and has no effect of any kind. It's a habit carried over from XHTML. JSX and MDX are stricter and reject an unclosed void element, so you must write <br /> there.
We prefer leaving the slash off in plain .html files and keeping it wherever JSX demands it. One more trap the spec warns about: a slash straight after an unquoted value joins the value. <img src=cat.jpg/> asks for a file called cat.jpg/.
How Attributes Work Inside the Start Tag
An attribute is a name="value" pair written inside the start tag, after the element name. It's how a tag in HTML carries settings like a link's destination or an image's source. You can add several, separated by spaces, in any order. Attributes never go in the end tag.
Quotes are optional for simple values, so class=nav is valid. They become required as soon as a value contains a space, a quote, =, <, > or a backtick. Quoting every value is the safer habit.
Boolean attributes such as disabled, checked and required work by presence alone. Writing required is enough. The catch: disabled="false" still disables the field, because the browser only checks whether the attribute exists.
Some attributes fit only certain elements, like href on links or src on images. Others are global and work on any element. The MDN global attributes reference lists them all. The ones you'll use most are id, class, style, title, lang, hidden and custom data-* attributes.
Nesting, Case and Optional End Tags: The Rules Browsers Apply
Elements nest like boxes, so you close tags in the reverse order you opened them. The first line below is correct. The second overlaps the tags, which is an error the browser has to guess its way out of.
<p>This is <strong>important</strong> text.</p>
<p>This is <strong>broken</p></strong>
Tag names are case-insensitive in HTML syntax, so <P>, <p> and <Div> all work. Write them in lowercase anyway, since that's what every style guide and tool expects. Attribute values are a different story: class names such as Nav and nav are not the same.
Some end tags are optional. The spec lets you omit the end tag of li, dt, dd, option, table rows and cells, and p in many cases. That last one causes a classic surprise:
<p>Intro text
<div>A block inside a paragraph?</div>
</p>
This doesn't nest the way it looks. A p element closes automatically when a div, ul or heading starts. The browser ends the paragraph before the div, and the stray </p> creates a second, empty paragraph.
Browsers recover from mistakes like these instead of refusing to render, which hides them from you. Our HTML formatter re-indents your markup so nesting mistakes stand out and runs a basic issue check. It isn't a validator, so for a full conformance check use the W3C's Nu Html Checker.
Which Tag Is Used for HTML? The Skeleton Every Page Starts With
The <html> tag wraps the whole document. Inside it, <head> holds information about the page and <body> holds everything the reader sees. A minimal, valid page looks like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My first page</title>
</head>
<body>
<h1>Hello</h1>
<p>This paragraph is visible on the page.</p>
</body>
</html>
<!DOCTYPE html>isn't a tag or an element. It's a required preamble that keeps browsers in standards mode instead of an older rendering mode.<html lang="en">is the root element. Thelangattribute tells screen readers and translators the page language.<meta charset="utf-8">sets the character encoding, and the viewportmetamakes the page scale on phones.<title>sets the page title shown in the browser tab, which search engines often use too.<body>contains the visible content: here, one heading and one paragraph.
The spec technically lets you omit the html, head and body tags, and the browser creates those elements anyway. Keep them. Every tutorial, template and tool assumes they're there.
HTML Tag List: Common Tags Grouped by What They Do
This HTML tag list covers the tags you'll reach for on almost every page, grouped by job. In the End tag column, "Optional" means the spec lets you leave it out, and "None" marks a void element.
Document and metadata tags
| Tag | What it does | End tag |
|---|---|---|
<html> | Root element that wraps the page | Optional |
<head> | Holds metadata, title, styles and scripts | Optional |
<title> | The page title shown in the browser tab | Yes |
<meta> | Adds metadata such as charset and viewport | None |
<link> | Connects an external resource, usually a stylesheet | None |
<style> | Holds CSS written inside the page | Yes |
<base> | Sets the base URL for relative links | None |
<body> | Contains all the visible content | Optional |
Page section tags
| Tag | What it does | End tag |
|---|---|---|
<header> | Intro content for a page or section | Yes |
<nav> | A block of main navigation links | Yes |
<main> | The dominant content of the page | Yes |
<article> | A self-contained piece, such as a post or comment | Yes |
<section> | A thematic group, normally with a heading | Yes |
<aside> | Side content, such as a sidebar or callout | Yes |
<footer> | Closing info for a page or section | Yes |
Heading tags h1 to h6
<h1> through <h6> are six heading levels, and each needs an end tag. Use h1 for the page title, h2 for main sections and h3 for subsections inside them. Don't skip levels, and don't pick a heading for its size, because CSS handles size. Several h1 elements are valid HTML, but MDN's guidance on heading elements advises one per page.
Text tags
| Tag | What it does | End tag |
|---|---|---|
<p> | A paragraph | Optional |
<br> | A line break inside text | None |
<hr> | A thematic break, drawn as a horizontal line | None |
<strong> | Strong importance, bold by default | Yes |
<em> | Stress emphasis, italic by default | Yes |
<b> | Draws attention without adding importance | Yes |
<i> | Set-apart text such as terms or foreign words | Yes |
<mark> | Highlighted text | Yes |
<small> | Side comments and fine print | Yes |
<sub> and <sup> | Subscript and superscript | Yes |
<code> | Inline computer code | Yes |
<pre> | Preformatted text that keeps its spacing | Yes |
<kbd> | Keyboard input, such as a shortcut | Yes |
<blockquote> | A long quotation from another source | Yes |
<q> | A short inline quotation | Yes |
<abbr> | An abbreviation or acronym | Yes |
<span> | Generic inline container with no meaning | Yes |
<div> | Generic block container with no meaning | Yes |
List tags
| Tag | What it does | End tag |
|---|---|---|
<ul> | Unordered, bulleted list | Yes |
<ol> | Ordered, numbered list | Yes |
<li> | One item in either list | Optional |
<dl> | Description list of terms and details | Yes |
<dt> | A term in a description list | Optional |
<dd> | The description for a term | Optional |
Link and media tags
| Tag | What it does | End tag |
|---|---|---|
<a> | A hyperlink, with href as the destination | Yes |
<img> | Embeds an image, with alt text | None |
<picture> | Offers different image sources per screen | Yes |
<source> | One media source inside picture, video or audio | None |
<video> | Embeds a video player | Yes |
<audio> | Embeds an audio player | Yes |
<iframe> | Embeds another web page | Yes |
<figure> | Self-contained content, such as an image or chart | Yes |
<figcaption> | The caption for a figure | Yes |
Table tags
| Tag | What it does | End tag |
|---|---|---|
<table> | Wraps the whole table | Yes |
<caption> | The table's title | Optional |
<thead> | Groups the header rows | Optional |
<tbody> | Groups the body rows | Optional |
<tr> | One table row | Optional |
<th> | A header cell | Optional |
<td> | A data cell | Optional |
Form tags
| Tag | What it does | End tag |
|---|---|---|
<form> | Collects input and submits it | Yes |
<label> | Names a form control | Yes |
<input> | One field: text, checkbox, date and more | None |
<textarea> | Multi-line text box | Yes |
<select> | A drop-down list | Yes |
<option> | One choice inside a select | Optional |
<button> | A clickable button | Yes |
<fieldset> | Groups related controls | Yes |
Scripting tags
| Tag | What it does | End tag |
|---|---|---|
<script> | Runs or loads JavaScript | Yes |
<noscript> | Fallback content when scripts are off | Yes |
<template> | Markup that isn't shown until a script uses it | Yes |
That's the working set, not the whole language. The MDN HTML elements reference lists every element, including rarer ones like details, dialog and output.
Obsolete HTML Tags and What Replaced Them
Old tutorials still teach tags that the current standard has dropped. The WHATWG list of obsolete features says authors must not use them. Browsers still render several, such as center and marquee, so old pages don't break, but a page using them doesn't conform.
| Obsolete tag | Use instead |
|---|---|
<font> | CSS color, font-family and font-size |
<center> | CSS text-align: center |
<big> | CSS, or <strong>, <mark> or a heading by meaning |
<tt> | <code>, <kbd>, <samp> or <var> |
<strike> | <del> for edits, <s> for anything else |
<acronym> | <abbr> |
<dir> | <ul> |
<marquee> and <blink> | CSS animation, used sparingly |
<frame> and <frameset> | <iframe> and CSS |
If you searched for the font tag, the fix is a stylesheet. Put color and font-family in a CSS rule and apply it with a class attribute.
How Markdown Marks Turn Into HTML Tags
Markdown is shorthand for a small set of HTML tags. When the file is converted, # becomes an h1, ** becomes strong, and a [text](url) link becomes an a element. Our guide on how to convert Markdown to HTML covers the full mapping and the conversion methods. For when to write which, see Markdown vs HTML.
The note below mixes Markdown with raw kbd and sub tags. Click Export HTML to see the tags each line produces.
The output contains h1, p, strong, em, ul, li, kbd, sub and a tags, wrapped in a full HTML document. The preview renders some raw HTML too, such as <kbd>, <sub>, <sup> and <details>. It strips scripts and event handlers, though, so it can't test HTML that relies on JavaScript.
A tag in HTML is only the marker: the element is what it builds, and attributes ride inside the start tag. Remember the 13 void elements, close tags in reverse order, and most markup bugs never happen. Paste messy markup into the HTML formatter to re-indent it, or write Markdown in the editor and let it produce the tags for you.