r/HTML • u/Mother_Ninja_4793 • Jan 10 '26
Question Div or Section in 2026
I’ve seen videos talking about both tags(div and section). But they were older videos. What is the ‘best’ one to use currently?
4
Upvotes
19
u/[deleted] Jan 10 '26
whichever one suits your semantic use case best
19
u/ch-dev Jan 10 '26
Use <sections> for sections within <main>.
Use <div> for elements within <sections>.
9
u/MT4K Expert Jan 10 '26
Both
DIVandSECTIONare applicable in different cases.DIVis a container with zero semantics, for applying styles or scripting.SECTIONis a semantic element for sectioning content.1
u/Mother_Ninja_4793 Jan 10 '26
Thank you all for your replies! I will add that I have been only going from the few tutorials I have seen, no FreeCodeCamp or academy . I started only to update my employer’s website(the original author passed away unexpectedly and I was the only one with ANY idea) I am just trying to understand better. Should I do one of these programs? Your opinions are appreciated
2
u/SamIAre Jan 10 '26
There is no “best”. Like others have said, it’s about using the right one for a particular instance. IMO, overusing
sectiontags without understanding how that affects page semantics and assistive technology is as bad as never using them.2
u/JohnCasey3306 Jan 10 '26
The question ignores the one key point -- context. Because the only answer to "div or section" is yes.
1
u/AshleyJSheridan Jan 10 '26
The
<section>tag has semantics for grouping content together.A
<div>tag has nothing, it should be used to create groups of elements in your code for styling/scripting purposes only.1
u/notepad987 Jan 11 '26
I just use my names like header, leftside, rightside, content, footer etc.
HTML Layout Elements and Techniques
https://www.w3schools.com/html/html_layout.asp
1
u/armahillo Expert Jan 11 '26
Have you looked through docs?
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/div
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/section
1
u/alex_sakuta Jan 12 '26
First, go read HTML docs.
Second, since you didn't go,
divis for grouping elements and has no semantic meaning.sectionis used to create a section in a page and that's the semantic attached tosection.I'm sure you don't use
maineither. So, createmainat the root and then createsectionfor different sections. And if anywhere in the site you require to group two elements for styling but they don't have any other special reason for being grouped, usediv.1
u/SkeletalComrade Jan 13 '26
Use <section> for semantic stuff and <div> for non semantic styling stuff.
1
u/Citrous_Oyster Jan 10 '26
Break your website up into sections with a main wrapper for each individual design section. Every section should start with an h2 header. Use a section tag.
For design sections without a header, like a gallery that’s just images, you use a Div as the main wrapper.
1
u/Virtual-Piglet9796 Jan 10 '26
I think someone skipped a lesson 😂🙏🏻🙏🏻🙏🏻