Should non-semantic elements be replaced by semantic wherever possible?

Should non-semantic elements be replaced by non-semantic elements whenever it is possible?

In other words, should non-semantic elements be avoided when there are semantic elements that can be used instead, or does it depends on the case, on the web developer preferences or on anything else?

Yes, that’s correct. Non-semantic HTML elements should be used when there are no semantic elements that can do the job.
Convention specifies it’s preferable to use semantic HTML elements within your code to improve readability, accessibility and SEO.

25 Likes

Thanks again, herebeandre. Another doubt solved :slight_smile:

3 Likes

If semantic elements are the preferred method of html coding, why were the first lessons (several hours of training) so focused on the non-semantic elements?

6 Likes

I imagine three reasons:

  • Non-semantic HTML elements are used when semantic HTML elements cannot be.
  • So you have the knowledge that they exist, so that when you’re reading another developer’s code, you’re aware of the function of non-semantic elements.
  • To my understanding, semantic HTML is a newer concept, so if you’re reading legacy code, you’re aware of the function of non-semantic elements.
17 Likes

yes that makes sense.

I found this video very informative on this subject. https://www.youtube.com/watch?v=uxmB8MlO3m8 The entire video is useful but if you want to skip to the section on “divitus” it is at minute marker 10:36. so about 8 minutes on this topic. The complete video is about semantics.

2 Likes