Using Class/ID in Semantic Tags

Working on this exercise: https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-22-fundamentals-of-html/modules/wdcp-22-semantic-html/lessons/semantic-html/exercises/main-and-footer

When I’m replacing the non-semantic “div” tags with semantic tags like “main” and “footer”, should I still keep an ID or Class associated with tag?

For example: main id=“main”. When referencing the element in the CSS file, is there any benefit from referencing from the actual element type, verse the element ID or class?

Thanks!

If we are to assume there will be only one MAIN element, then that is enough to hook it with CSS or JS (using a type selector). The only reason for giving it an id is if one wishes to hook it with an HREF…

 <a href="#main">Main</a>
1 Like