In HTML5, <header>, <footer>, <main>, and <aside> are semantic elements that help structure and organize the content of a web page. Here's a brief description of each:
<header>:
- Purpose: The <header> element typically represents the header or introductory content of a section or a page. It often includes headings, logos, navigation menus, and other introductory elements.
- Placement: It's commonly placed at the top of a page or within a specific section to provide introductory information.
<header>
<h1>Website Title</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
<footer>:
- Purpose: The <footer> element represents the footer or closing content of a section or a page. It often contains copyright information, links to legal statements, contact details, or other information relevant to the end of the content.
- Placement: It's commonly placed at the bottom of a page or within a specific section to provide concluding information.
<footer>
<p>© 2023 My Website. All rights reserved.</p>
<p>Contact: [email protected]</p>
</footer>
<main>:
- Purpose: The <main> element is used to encapsulate the main content of a document. It should not include content that is repeated across multiple pages, such as headers or footers. It helps screen readers and other assistive technologies identify the main content area.
- Placement: It typically surrounds the central content of the page.
<main>
<article>
<h2>Article Title</h2>
<p>Content of the article...</p>
</article>
<!-- Additional articles or content -->
</main>
<aside>:
- Purpose: The <aside> element is used for content that is tangentially related to the content around it. It can be used for sidebars, pull quotes, or other content that is related but not the main focus.
- Placement: It's often placed alongside the main content but not necessarily inside it.
<main>
<article>
<h2>Article Title</h2>
<p>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>
</article>
</main>
Using these semantic elements helps improve the structure and accessibility of a web page by providing clear information about the purpose and relationship of different sections of content.