WHY USE SEMANTIC ELEMENTS?
The main purpose of this article is to understand the purpose of semantic tags a little bit.
I’ve taken educations about computer science. After a while, I started to interest in web technologies. I’m new to web development. So, when I heard about semantic tags, the first question was “What are these semantic tags?”.
I’ve read and learned, tags in HTML are used to format the content, and new semantic tags are doing the same. The purpose of semantic tags is indicating the type and the role of the content. For example; you can use the “<div>” tag with a class or id as “article” to contain an article. But the “<div>” tag doesn’t give any clue about the content. Adding classes or ids to tags is not an efficient way to indicate their content. Instead of it, we must use the new, semantic “<article>” tag to contain an article.
Those two different ways are doing pretty much the same thing. Now, the new question is “Why?”.
Why should I learn and use semantic tags? What is the reason behind indicating the role or the type of content by its tag? In general, developers are interested in tags, and users are interested in the content. So, who actually needs semantic tags, and why?
Let’s take a look at an example below;
- Semantic elements
- Non-semantic elements
So, we can see that one reason is, there is an improvement in readability. This is a little piece of code. But while coding, it can be thousands of lines long.
Another reason is, it is better for search engines and browsers too!
We create content, develop web pages to publish and share them. And it is important to display everything. Semantic tags make communication better and clearer with the browser. Also, they describe the meanings and contents of a page much better.
A purpose of ours is to reach out to people, as many as we can, who interested in our content. These semantic tags also helpful for search engines in the same way. It’s a way to optimize our pages for them. And it helps your content to be shown in the correct results of search queries.
I’ve tried to explain what semantic tags are and why we must use them. But of course, there is much more to learn. There are a few links to my resources below, so you can read more if you are interested.