{"id":801,"date":"2025-02-14T00:14:20","date_gmt":"2025-02-14T00:14:20","guid":{"rendered":"https:\/\/www.woodcentral.com\/-\/peter\/?p=801"},"modified":"2026-05-24T11:28:32","modified_gmt":"2026-05-24T11:28:32","slug":"how-to-use-html5-semantic-elements","status":"publish","type":"post","link":"https:\/\/www.woodcentral.com\/-\/peter\/how-to-use-html5-semantic-elements\/","title":{"rendered":"How to use HTML5 semantic elements"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In HTML5, semantic elements like <code>&lt;section&gt;<\/code>, <code>&lt;article&gt;<\/code>, <code>&lt;nav&gt;<\/code>, <code>&lt;header&gt;<\/code>, <code>&lt;footer&gt;<\/code>, and others are introduced to improve the structure and readability of the web content. These elements help both developers and browsers better understand the content of a webpage. Here&#8217;s an overview of the most commonly used HTML5 semantic elements and how they should be used and nested:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong><code>&lt;section&gt;<\/code><\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Purpose<\/strong>: The <code>&lt;section><\/code> element is used to represent a thematic grouping of content, often with its own heading. It helps to divide the page into sections of related content.<\/li>\n\n\n\n<li><strong>Use case<\/strong>: It\u2019s commonly used for areas such as chapters, tabs, or any grouping of content that could be considered as a standalone section.<\/li>\n\n\n\n<li><strong>Nesting<\/strong>: You can nest <code>&lt;section><\/code> elements inside one another if the content is related. However, each <code>&lt;section><\/code> should ideally have a heading (<code>&lt;h1><\/code>, <code>&lt;h2><\/code>, etc.) to define the section&#8217;s topic clearly.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;section&gt;\n    &lt;h2&gt;Introduction&lt;\/h2&gt;\n    &lt;p&gt;This is the introduction to the article...&lt;\/p&gt;\n&lt;\/section&gt;\n\n&lt;section&gt;\n    &lt;h2&gt;Main Content&lt;\/h2&gt;\n    &lt;p&gt;This is the main content of the article...&lt;\/p&gt;\n&lt;\/section&gt;\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong><code>&lt;article&gt;<\/code><\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Purpose<\/strong>: The <code>&lt;article><\/code> element is meant for content that is self-contained and can be independently distributed or reused, such as a blog post, news article, or forum post. It&#8217;s typically used for any content that makes sense on its own and could be syndicated or shared independently.<\/li>\n\n\n\n<li><strong>Use case<\/strong>: Articles are typically self-contained pieces of content, like blog posts or product reviews.<\/li>\n\n\n\n<li><strong>Nesting<\/strong>: Articles can be placed inside sections. However, they should not be nested inside each other. A section can contain multiple articles, but each article should stand alone.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;article&gt;\n    &lt;h2&gt;Article Title&lt;\/h2&gt;\n    &lt;p&gt;Article content goes here...&lt;\/p&gt;\n&lt;\/article&gt;\n\n&lt;article&gt;\n    &lt;h2&gt;Another Article&lt;\/h2&gt;\n    &lt;p&gt;Another set of article content...&lt;\/p&gt;\n&lt;\/article&gt;\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong><code>&lt;nav&gt;<\/code><\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Purpose<\/strong>: The <code>&lt;nav><\/code> element represents a section of a page that links to other pages or sections of the same page. It is used for navigation menus.<\/li>\n\n\n\n<li><strong>Use case<\/strong>: Use it for menus, tables of contents, or any set of links that facilitate navigation.<\/li>\n\n\n\n<li><strong>Nesting<\/strong>: A <code>&lt;nav><\/code> element can be placed inside a section, article, or anywhere else appropriate. It should contain links (<code>&lt;a><\/code>) that point to relevant destinations.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;nav&gt;\n    &lt;ul&gt;\n        &lt;li&gt;&lt;a href=\"#home\"&gt;Home&lt;\/a&gt;&lt;\/li&gt;\n        &lt;li&gt;&lt;a href=\"#about\"&gt;About&lt;\/a&gt;&lt;\/li&gt;\n        &lt;li&gt;&lt;a href=\"#contact\"&gt;Contact&lt;\/a&gt;&lt;\/li&gt;\n    &lt;\/ul&gt;\n&lt;\/nav&gt;\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. <strong><code>&lt;header&gt;<\/code><\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Purpose<\/strong>: The <code>&lt;header><\/code> element represents introductory content for a section or an entire page, often containing a logo, navigation, or headings.<\/li>\n\n\n\n<li><strong>Use case<\/strong>: The <code>&lt;header><\/code> can be used for site-wide navigation, titles, or even for introductory content at the beginning of a section or article.<\/li>\n\n\n\n<li><strong>Nesting<\/strong>: A <code>&lt;header><\/code> can be used inside a <code>&lt;section><\/code>, <code>&lt;article><\/code>, or <code>&lt;body><\/code>. You can have multiple headers within a page, but each should be related to its specific content.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;header&gt;\n    &lt;h1&gt;Welcome to My Website&lt;\/h1&gt;\n    &lt;nav&gt;\n        &lt;a href=\"#home\"&gt;Home&lt;\/a&gt;\n        &lt;a href=\"#about\"&gt;About&lt;\/a&gt;\n    &lt;\/nav&gt;\n&lt;\/header&gt;\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. <strong><code>&lt;footer&gt;<\/code><\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Purpose<\/strong>: The <code>&lt;footer><\/code> element defines the footer of a section or an entire page. It typically contains information like copyright notices, contact information, or links to related content.<\/li>\n\n\n\n<li><strong>Use case<\/strong>: Footers often hold information like copyright, terms of service, or privacy policy links.<\/li>\n\n\n\n<li><strong>Nesting<\/strong>: Similar to <code>&lt;header><\/code>, the <code>&lt;footer><\/code> element can be used at the bottom of sections, articles, or the entire document. It should generally not be nested inside other footers.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;footer&gt;\n    &lt;p&gt;&amp;copy; 2025 My Website. All rights reserved.&lt;\/p&gt;\n&lt;\/footer&gt;\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. <strong><code>&lt;aside&gt;<\/code><\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Purpose<\/strong>: The <code>&lt;aside><\/code> element represents content that is tangentially related to the content around it, such as a sidebar, related links, or additional information. It\u2019s often used for sidebars, advertisements, or related resources.<\/li>\n\n\n\n<li><strong>Use case<\/strong>: Asides are used for content that is not central to the page but may still be relevant (like a sidebar or a pull quote).<\/li>\n\n\n\n<li><strong>Nesting<\/strong>: An <code>&lt;aside><\/code> can be placed inside sections or articles, but it should not be nested too deeply within the content, as it&#8217;s meant to be secondary.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;aside&gt;\n    &lt;h2&gt;Related Articles&lt;\/h2&gt;\n    &lt;ul&gt;\n        &lt;li&gt;&lt;a href=\"#article1\"&gt;Article 1&lt;\/a&gt;&lt;\/li&gt;\n        &lt;li&gt;&lt;a href=\"#article2\"&gt;Article 2&lt;\/a&gt;&lt;\/li&gt;\n    &lt;\/ul&gt;\n&lt;\/aside&gt;\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Guidelines for Nesting:<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Logical Hierarchy<\/strong>: Elements should be used logically. For example, <code>&lt;article><\/code> elements can be grouped in a <code>&lt;section><\/code>, but don&#8217;t nest <code>&lt;article><\/code> within another <code>&lt;article><\/code>.<\/li>\n\n\n\n<li><strong>Clarity<\/strong>: Each section or article should have its own header to clarify what the content pertains to.<\/li>\n\n\n\n<li><strong>Avoid Overuse<\/strong>: Not every block of content needs to be wrapped in a <code>&lt;section><\/code>. Only use <code>&lt;section><\/code> for thematic grouping, and <code>&lt;article><\/code> when the content is self-contained.<\/li>\n\n\n\n<li><strong>Accessibility and SEO<\/strong>: These elements also help with accessibility, as screen readers and search engines can better interpret the structure of the page.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Example Structure:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n    &lt;meta charset=\"UTF-8\"&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\n    &lt;title&gt;Example Page&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;header&gt;\n        &lt;h1&gt;Website Title&lt;\/h1&gt;\n        &lt;nav&gt;\n            &lt;a href=\"#home\"&gt;Home&lt;\/a&gt;\n            &lt;a href=\"#about\"&gt;About&lt;\/a&gt;\n        &lt;\/nav&gt;\n    &lt;\/header&gt;\n\n    &lt;main&gt;\n        &lt;section&gt;\n            &lt;h2&gt;Introduction&lt;\/h2&gt;\n            &lt;p&gt;This section introduces the main content...&lt;\/p&gt;\n        &lt;\/section&gt;\n\n        &lt;section&gt;\n            &lt;h2&gt;Content&lt;\/h2&gt;\n            &lt;article&gt;\n                &lt;h3&gt;Article 1&lt;\/h3&gt;\n                &lt;p&gt;This is the first article...&lt;\/p&gt;\n            &lt;\/article&gt;\n            &lt;article&gt;\n                &lt;h3&gt;Article 2&lt;\/h3&gt;\n                &lt;p&gt;This is the second article...&lt;\/p&gt;\n            &lt;\/article&gt;\n        &lt;\/section&gt;\n\n        &lt;aside&gt;\n            &lt;h3&gt;Related Content&lt;\/h3&gt;\n            &lt;ul&gt;\n                &lt;li&gt;&lt;a href=\"#\"&gt;Link 1&lt;\/a&gt;&lt;\/li&gt;\n                &lt;li&gt;&lt;a href=\"#\"&gt;Link 2&lt;\/a&gt;&lt;\/li&gt;\n            &lt;\/ul&gt;\n        &lt;\/aside&gt;\n    &lt;\/main&gt;\n\n    &lt;footer&gt;\n        &lt;p&gt;&amp;copy; 2025 My Website&lt;\/p&gt;\n    &lt;\/footer&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <code>&lt;header><\/code> contains site-wide content like the title and navigation.<\/li>\n\n\n\n<li>The <code>&lt;main><\/code> contains sections of the page, each with its own content, including articles.<\/li>\n\n\n\n<li>The <code>&lt;aside><\/code> is used for secondary or tangential content.<\/li>\n\n\n\n<li>The <code>&lt;footer><\/code> holds the copyright information.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">These elements help make the page more structured and improve the semantic meaning of the content, benefiting both users and search engines.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In HTML5, semantic elements like &lt;section&gt;, &lt;article&gt;, &lt;nav&gt;, &lt;header&gt;, &lt;footer&gt;, and others are introduced to improve the structure and readability of the web content. These elements help both developers and browsers better understand the content of a webpage. Here&#8217;s an overview of the most commonly used HTML5 semantic elements and how they should be used &#8230; <a title=\"How to use HTML5 semantic elements\" class=\"read-more\" href=\"https:\/\/www.woodcentral.com\/-\/peter\/how-to-use-html5-semantic-elements\/\" aria-label=\"Read more about How to use HTML5 semantic elements\">Read more<\/a><\/p>\n","protected":false},"author":7,"featured_media":807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-801","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.woodcentral.com\/-\/peter\/wp-json\/wp\/v2\/posts\/801","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.woodcentral.com\/-\/peter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.woodcentral.com\/-\/peter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.woodcentral.com\/-\/peter\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.woodcentral.com\/-\/peter\/wp-json\/wp\/v2\/comments?post=801"}],"version-history":[{"count":0,"href":"https:\/\/www.woodcentral.com\/-\/peter\/wp-json\/wp\/v2\/posts\/801\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.woodcentral.com\/-\/peter\/wp-json\/wp\/v2\/media\/807"}],"wp:attachment":[{"href":"https:\/\/www.woodcentral.com\/-\/peter\/wp-json\/wp\/v2\/media?parent=801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.woodcentral.com\/-\/peter\/wp-json\/wp\/v2\/categories?post=801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.woodcentral.com\/-\/peter\/wp-json\/wp\/v2\/tags?post=801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}