What is semantic HTML?
Semantic HTML is using specific tags when writing HTML. These tags convey meaning about their intended purpose. Both humans and computers can understand the meaning of your code when you use them. Browsers, search engines and assistive technologies use these tags to create a better user experience.
Why should I use it?
It makes your code easy to read. You’ll be able to scan quickly through the code to understand how it is structured. Semantic tags also make it faster to write code. You don’t have as many decisions to make when you use the semantic tags.
How to get started?
HTML5 introduced new tags – semantic tags. Tags like
<footer>. With these tags, you create a web page structure that is readable to both search engines and people.
Your main content lives inside
<main>. You can use tags like
<p> and heading tags like
<h1> to provide some structure. To provide further meaning to the content, use tags like
<article> tag contains content that can be removed and put on another page. You can use the
<section> tag when you need to wrap groups of related content. Use the HTML semantics cheat sheet to learn when to use which tags for the right job.
What about the
HTML has non-semantic tags like
<div>. Its generic nature allows you to define its purpose through code. You can use the
<span> tags in your code. Use them to group elements that don’t have any specific meaning. When you need more specific meaning, choose semantic tags over non-semantic ones.