What is Semantic HTML, and why it is Important

·

3 min read

HTML, known as “Hypertext Markup Language,” is the web's primary scripting language or building block. It describes the meaning and structure of a given web page or content. Every other web developer starts off the development journey by at least acquainting themselves with the basics of the scripting language, including developing an understanding of how it describes and builds the web.

What is semantic HTML? It is a method of conveying meaning to a web page. Defining the structure through HTML is not enough for the developer or the browser to understand the importance of various elements. For instance, a non-semantic element such as div is generic and conveys no information regarding the content inside it. On the other hand, a semantic feature such as

can give meaning to the developer or browser on the nature and type of content within it.

Types of Semantic Tags

Multiple semantic tags can be used to convey meaning to HTML documents. The most common elements include:

<header>

The tag defines a web page header, typically containing logo or branding information.

<nav>

The nav tag defines the navigation links on a web page.

<article>

The article element defines an independent and self-contained piece of content, including a blog post, among other examples.

<aside>

The tag defines a secondary set or group of content that is not required or compulsory to understand the main content of a web page.

<section>

The tag defines a standalone section in an HTML document. Usually, it is used within the body or the article element.

<main>

The element defines the main content of a web page or section.

<h1>
<h2>
<h3>

The elements define the headings in a web page, with h1 representing the most significant heading and h6 describing the least.

What is the Importance of Semantic HTML?

Semantic HTML is required to convey meaning to the developer and browser of a given HTML document. It also allows for a proper understanding of the type and nature of the content on a given web page by various search engines such as Google. In addition, the modern times in web development require that content is accessible to all, including persons with disability. Fortunately, semantic HTML allows various accessibility software to understand the content of any web page.

Best Practices to Improve your Web Development

Considering the profound role of semantic HTML, it is important, as a developer, to observe the following:

- Don't Overuse the h1 tag.

For proper indexing of your webpage, it is essential to avoid using multiple h1 tags. Instead, use only once on a web page, followed by other levels such as h2 where necessary.

- Maintain some level of consistency with your HTML tags-Don't skip!

It is usually the best practice to move from level 1 to level 2, then level 3 headings, other than jumping from level 1 to level 3. That can be understood using the code below:

Avoid this:

<h1>Our Services</h1>
<h3>Contact Us</h3>
<h5>Read our blogs</h5>

Instead, ensure some level of consistency.

<h1>Our Services</h1>
<h2>Contact Us</h2>
<h3>Read our blogs</h3>

- Avoid using the div tag for significant sections such as headers and footers.

For semantics purposes, it is best to use semantic tags such as header, footer, and section tags to define the significant parts of a web page other than the generic div.