The aside element in HTML5 is used to denote content that is indirectly related to the content around it. This means the content in an <aside> related to the main content but is not important for it and could be considered separate. It can be used for sidebars, pull quotes, advertising, or secondary navigation. The placement of <aside> doesn’t define it; rather, it’s the relationship of its content to the surrounding content.
<aside> as the HTML5 equal of a newspaper or magazine sidebar. However, it’s critical to understand that the <aside> element is not defined by its position on the page. Just because content appears on the side doesn’t automatically make it an <aside>. As an alternative, it’s the relationship of the content to the main flow that controls whether to use <aside>.
Outside of an <article> element
In this case, the <aside> contains content that is related to the entire page or document. Common examples include:
- Sidebars with related links.
- Lists of recent posts.
- A search box.
- Advertisements.
- Groups of navigation elements (though <nav> might be more appropriate for major navigation).
This example shows an <aside> element containing two <section> elements, each representing a block within a sidebar. This sidebar content is tangentially related to the main content of the page.
Example
<body>
<header>
<h1>Main Content of the Page</h1>
<nav>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
</ul>
</nav>
</header>
<article>
<h2>Main Article Section</h2>
<p>This is the main content of the page. It contains important information...</p>
</article>
<aside id="sidebar">
<h3>Related Information</h3>
<ul>
<li><a href="#">Related Article A</a></li>
<li><a href="#">Related Article B</a></li>
<li><a href="#">Archives</a></li>
</ul>
</aside>
<footer>
<p>© 2023 Website Name</p>
</footer>
</body>
Main Content of the Page
Main Article Section
This is the main content of the page. It contains important information…