The Importance Of Semantic Tags In HTML

Hypertext Markup Language, popularly known as HTML, is the markup language for the web. It represents the structure and content of the web page. HTML is responsible for everything you see on any webpage, from the buttons to the images and the text. It is the skeletal structure of the webpage and is the foundational unit of many websites you see today.

Semantic HTML tags refer to tags that infer their contents based on their tag names. This simply means that you can have an idea of the content of an HTML tag just from the tag name. Some of the semantic HTML tags include header, nav, footer, section, and aside. For instance, a header tag implies that the content in the header tag is for the web page's header. Here are some of the important uses of semantic HTML tags.

  1. Accessibility

Picture this scenario: you're at your computer, but your mouse isn't working. Undeterred, you try to navigate a website using your keyboard. However, you soon realize that the website doesn't respond to keyboard commands, blocking you from completing your intended tasks. This is a classic example of an accessibility issue in web development.

Now, let's delve into what 'accessibility' really means in this context. In the realm of web development, accessibility is all about crafting websites that cater to diverse user needs. This inclusivity extends beyond just mouse users to encompass keyboard users and screen reader users. Often, developers fall into the trap of assuming everyone navigates websites with a mouse, neglecting those who rely on other tools. For instance, visually impaired users or those with certain disabilities may use screen readers to audibly convey the text on the screen. Similarly, keyboard users depend on keystrokes to journey through web pages. By considering these varied user experiences, web developers can create more accessible and user-friendly websites.

Here’s the thing: the browser understands the meaning of a page and each of its tags. There is no specific context for the HTML tag ’div’, the browser would not clearly understand the content of the page, and this would lead to a certain fraction of users not being able to get the optimal user experience. The use of semantic HTML tags helps the browser understand the content of the web page, and this in turn increases the website’s accessibility.

In addition, the screen reader reads out the content of the web page to the user; hence, the need for the appropriate use of semantic HTML tags. As stated already, HTML is primarily used for structuring web pages, using a header tag where a section tag should be would not reflect in the user interface (UI). The UI would still look as it should, but when the screen reader reads the web page's content, a wrong description of the element would be given, which could confuse the end user.

Categorically speaking, accessibility is mainly overlooked by smaller firms and businesses, but take, for instance, a company as big as Shopify, where about 1% of their users make use of either screen readers or the keyboard. As of this write-up, Shopify has 2.1 million daily active users. 1% of this is over twenty thousand customers. Now, imagine losing over twenty thousand customers just because the developer didn't account for accessibility. It would be catastrophic for a company of even that size.

  1. SEO

Quick question! When making use of the search engine, how often do you move away from the first search page to the next? The majority of users find their answers on either the first search page or the second. Ideally, no one wants their website on the third or fourth page of search engines because of the minimal traffic it would get. Now, how do these search engines rank these websites? This is where SEO comes into play.

Search Engine Optimization involves a set of practices aimed at making websites rank higher on search engines like Google, Bing, and Yahoo. This helps in increasing the quantity and quality of organic traffic to a website. SEO involves several techniques to enhance a site’s relevance in the eyes of search engines, making it more likely to appear when users enter relevant queries. One of the several techniques to improve SEO is using semantic HTML tags.

In other words, using semantic HTML tags like header, aside, footer, etc. ensures that search engines see your content and understand it. It is like telling the search engine what each section of the page entails. The use of divs doesn't give the search engine enough information; a div could contain anything, but an aside tag tells the browser specifically that it contains content aside from the main content.

Now, you might be wondering how the browser understands these semantic HTML tags. It does this with the use of web crawlers. Web crawlers play a crucial role in interpreting semantic HTML tags on a website. Web crawlers index HTML pages by parsing HTML content; they recognize these semantic HTML tags, which help the browser understand the webpage structure and also contribute to improved user experience.

Before the introduction of semantic HTML tags, developers often relied on some techniques to improve their web pages’ SEO. Some of these techniques include keyword optimization, crafting effective meta tags, link building, etc. These techniques are all well and good as they aim to achieve a common goal but the use of semantic HTML tags took SEO optimization to the next level. This is because they are still normal HTML tags, but just more descriptive and now SEO-optimized.

  1. Code Readability

Reading other people’s code in software engineering is a top skill. Some developers are excellent but find it hard to collaborate and work with other developers because of the difference in their code-writing conventions and organization. Now, the inability to understand the code by another developer doesn’t necessarily mean you’re not a good developer; it could boil down to a lot of things, like the codebase being too bloated, the developer’s code convention, etc.

Code readability refers to the ease with which someone can comprehend and understand the logic of code written by another person. It is a key aspect of software engineering as it plays a key role in the success and development of any project. Well-written and easily understandable code improves development efficiency and makes it easier to manage projects, no matter how complex.

Moreover, when structuring the webpage using HTML, the presentation of the code matters a lot because it makes it more readable. Many factors contribute to the presentation of your HTML, like proper nesting of HTML tags, use of semantic HTML tags, etc. Semantic HTML tags are descriptive enough and give enough information for any other person reading your code or even you. Semantic HTML tags like summary, section, article, etc., are readable and self-explanatory, which makes the code more comprehensive.

As stated above, semantic HTML tags infer their contents, and this helps a lot in code readability. This is very important for collaborative projects. When multiple people are working on a project, it is always advisable to adhere to the best practices so that the codebase is seamless for all developers, which eases the development process. The best practice while writing HTML is to make use of the semantic HTML tags where necessary, as this speeds up the development process, as it is widely adopted now, and it would be comprehensive for the other developers on the project.

Semantic HTML Tags- The Way Forward

Bottom line? The use of semantic HTML tags has become very notable amongst developers because of their ease and benefits. As a developer, you should always try to use semantic HTML tags wherever possible rather than divs. Div tags are not obsolete, but rather, they should not be used like they were before. There are still certain use cases for the div tags, but they should only be used in appropriate situations where semantic tags would not be needed.

0
Subscribe to my newsletter

Read articles from Emorinken Samuel directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Emorinken Samuel
Emorinken Samuel

I’m me, I do me, and I chill.