Learn about semantic elements in HTML for better structure and accessibility
1. What are Semantic Elements?
Semantic elements clearly describe their meaning in a way that is both human- and machine-readable. Using semantic HTML improves the accessibility and SEO of your web pages.
Note: Semantic elements help search engines and screen readers understand the structure and content of a webpage better.
2. Common Semantic Elements
Here are some of the most commonly used semantic elements in HTML:
<header>: Represents introductory content or a set of navigational links.
<nav>: Defines a section of navigation links.
<main>: Specifies the main content of the document.
<section>: Defines a section in a document, like a chapter in a book.
<article>: Represents independent content, like a blog post or a news article.
<aside>: Contains content indirectly related to the main content, like sidebars or advertisements.
<footer>: Defines the footer of a document or a section.
<figure>: Represents self-contained content, like images or diagrams, often with a caption.
<figcaption>: Provides a caption for the <figure> element.
<mark>: Highlights text to draw attention to it, like highlighting search terms.
3. Example of Semantic Elements in Action
This example demonstrates how to use semantic elements to structure a simple webpage: