HTML aside Tag
The HTML `<aside>` tag represents a portion of a document whose content is only indirectly related to the document's main content. Asides are frequently presented as sidebars or call-out boxes
Basic Syntax
html
<article>
<h2>Main Article Title</h2>
<p>This is the primary content of the article...</p>
<aside>
<h3>Related Links</h3>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
</ul>
</aside>
<p>More primary content...</p>
</article>
<aside>
<h4>About the Author</h4>
<p>John Doe is a web developer with 10 years of experience...</p>
</aside>
Key Characteristics
- Tangential Content: The content within an<aside>
should be related to the surrounding content but distinct from it. - Placement: While often used for sidebars, an
<aside>
can appear anywhere in the document flow. Its semantic meaning is not tied to its visual placement. - Context is Key: If an
<aside>
is within an <article>
element, its content should be related to that article. If it's outside an <article>
(but within another sectioning element or at the <body>
level), it should be related to the site or page as a whole (e.g., a site-wide navigation block, a list of recent posts).
Common Use Cases
- Sidebars: Containing navigation links, related articles, advertisements, author bios, etc.- Pull Quotes: Visually distinct quotes from the main text.
- Glossary Information: Definitions or explanations related to the main content.
- Author Information: If an
<aside>
is inside an <article>
's footer. - Advertising Blocks.
aside vs. section vs. div
-<aside>
: For content that is tangentially related to the main content. It's a type of sectioning content but with a specific semantic role. -
<section>
: For grouping thematically related content. This content is typically a direct part of the main flow. -
<div>
: A generic non-semantic container used for styling or scripting purposes when no other more specific element is appropriate.
If the content is essential to understanding the main topic, it probably doesn't belong in an <aside>
. If it's directly part of the main narrative or a distinct thematic block within it, <section>
might be better.