Trying to understand the difference between section and div

from my understanding ‘div’ lets you turn a group of code into a block and things can be modified in that block

section is almost like div, but you can modify more things at once than you can in div. It is a little more powerful than div.

I think I understand it. In some cases it may be better to use section instead of div.

Section tells browsers and screen readers that the content inside it should be grouped together, like a section in an article.
Div does not impart any meaning and is simply used to help with layout.

As far as I know, there’s absolutely no difference in functionality between <section> and <div> elements. Pretty sure you could replace all your section elements with divs (or all divs with section elements) and you’d see no difference.

However – section elements are ‘semantic.’ Meaning, they describe what they’re being used for. When you see a <section> then you sort of have an idea that it’s wrapping a ‘section of a webpage’ whereas a div doesn’t really mean anything specific. So using <section> properly is good for code readability and it’s good for screen readers (devices used for browsing the internet for people with vision impairment). Same can be said for <header>, <footer>, <article>, etc.

1 Like

Yes, thanks for your reply. It will take to time for me to definitely about which one to chose to use when coding on my own.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.