The goals of Semantic HTML are to create meaningul elements in the code that:
- help screen readers navigate our pages
- help other coders understand our code
- improve SEO of our website
How can HTML be Semantic?
Semantic as defined by Google is "relating to meaning in language or logic." In this case we are creating and HTML code with meanings embedded into it. Semantic HTML replaces the <div> elements. As a reminder, <div> is an element that we use to group items on our page. However, since it is a basic element with no helpful information inside of it, we have to use attributes. These are the id and class tags that are added within the <div> element. This may appear like
<div id='nav'></div>
A replacement of this code in semantic HTML would appear like
<nav></nav>
This difference helps both front and back end users interact with your website. As previously mentioned, a screen reader can help users interact with your website navigation easier since it is outlined specifically in your code. The next programmer to look at your code would easily find your navigation code for updating purposes. Finally when you are making the stylesheet for your website, you have elements rather than class tags to help yourself with styling.