Semantic HTML Elements
Write better HTML code by using semantic elements.

I'm a full stack developer based in Australia. I write articles about Node.js, React, JavaScript & Web Development to make your learning journey easier ๐
Search for a command to run...
Write better HTML code by using semantic elements.

I'm a full stack developer based in Australia. I write articles about Node.js, React, JavaScript & Web Development to make your learning journey easier ๐
No comments yet. Be the first to comment.
Introduction Website performance is an important aspect of web development. It consists of mainly two things: The speed of your website How usable is your website for visitors? Importance of website performance Website performance is very importa...

There are plenty of native web APIs that have a variety of uses. Here are 5 useful APIs that I use quite often in my web development projects. Clipboard API The clipboard API is a simple method to copy text to a user's clipboard. This can be used in ...

Hey All ๐ In this article, we'll be covering the Fetch API in JavaScript how you can use it to make HTTP requests. What is the Fetch API? The fetch() method provides a simple way to make HTTP requests in JavaScript. It is natively in the browser, me...

Hey All ๐ In this article, we'll be covering 4 mistakes commonly made by people while learning to code that will seriously impact their coding journey. #1 - Copying and Pasting The first mistake I'll talk about is copying and pasting. We've all don...

Introduction There are plenty of units in CSS. From px to vh, there is an abundance of units all with their distinctive use cases. Considering the amount of options, its perfectly reasonably to be confused as to which unit you should use and where. T...

In this article, we will be discussing how to use semantic HTML elements, which are elements that clearly describe their meaning. These can be very useful is writing better HTML code that is more readable for both the developer and browser.
Semantic HTMl elements are elements that clearly describe their meaning to both the browser and the developer. Some examples include: <form>, <table> and <nav>.
When building front end websites with HTMl, you will often find yourself using divs with classes like nav, header and footer to indiciate navigations, headers and footers. However in HTML5, you can use semantic elements that define different parts of the web page. The following is a list of the most commonly used semantic elements in HTML that you can start using:
<article><section><nav><footer><aside><header><article> ElementThe <article> element specifies independent, self-contained content. An article should be completely understandable on its own even if the rest of the content present on the website was not there. An <article> element could be used for a variety of content including blog posts, newspaper articles and forum posts. For example, the following code could be used to display an article.
<article>Independent content that should be readable on its own</article>
<section> ElementAs the name suggests, the <section> element defines a section in a document. There are many possible sections on web pages. For instance, contact information could be put into its own section. As an example, the following code could be used to display a section of a document.
<section>
<h1>Contact Us</h1>
<p>Phone: 0000-000-000</p>
<p>Email: hello@ourcompany.com</p>
</section>
Note: Sections and articles are very similar and you can nest articles in sections and vice-versa.
<nav> ElementThe navigation element (<nav>) specifies a set of navigation links. For example, the following code displays a very simply navigation bar.
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
<ul>
</nav>
Note: The <nav> element should only be used for major block of navigation links and not all links within a document.
<footer> ElementThe <footer> element defines a footer section in a document. Footers are usually placed at the bottom of websites and typically contain information like copyright information and back to top links. The following code is a very simple footer to demonstrate its use.
<footer>
<p>Copyright 2021. Blake Y</p>
<p><a href="mailto:contact@blakeyeboah.com">contact@blakeyeboah.com</a></p>
</footer>
<aside> ElementThe <aside> element defines content aside from the content it is placed in. For example, the <aside> could be used for a sidebar since it doesn't directly relate to its surrounding content. The following code would be used to display a simple sidebar.
<aside>
<h3>Sidebar</h3>
<p>This is my sidebar</p>
</aside>
<header> ElementThe <header> element signifies a container for introductory content. For example, you could place a navigation bar within a header. Interestingly, you can have multiple headers within a document however, <header> can't be places within a <footer>, a <address> or another <header>. As an example, the following code displays a simple navigation bar within a header.
<header>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
<ul>
</nav>
</header>
There are more semantic elements out there that you can look into after reading this article. I hope you apply the knowledge you've learnt to your current and future projects.
๐ Thanks for reading this article!
If you like what I do and would love to see more related content, follow me on my other social platforms:
GitHub: Blake-K-Yeboah
LinkedIn: Blake-K-Yeboah
You can also show your support by buying me a coffee ๐