With semantic HTML, do we no longer use the div element?

If I am not mistaken divs are free elements. It means while using CSS, even if the div is nested within another element ie. main , footer , they can still be styled using just class and id selectors.
And I don’t think its possible with the sections.

1 Like

You’re free to do whatever you want. Semantic HTML is just there to allow you to improve your website’s performance, such as SEO rankings and user accessibility. A <div> and a <section> could both be used for the same purpose, but try to use the element that would make the most sense in your situation.

Ask yourself, is this element used to group a large section of my website that should be isolated from other large sections of my website (such as an about me section)? If so, use the section element. If you simply want to group elements for styling purposes (like grouping your title and subtitle for the sole purpose of giving them unique fonts) then use a div element

If you think about it, with enough styling and JavaScript, you could turn an input element into a simple container that behaves just like a div. Why won’t you do it? That’s because it just doesn’t make sense to use an input element as a styling container.

1 Like