instead of article,header,section,footer?
basically ever site i inspect, its filled with div. why is that?
are those semantic elements used IRL anyway?
instead of article,header,section,footer?
basically ever site i inspect, its filled with div. why is that?
are those semantic elements used IRL anyway?
@BaidDSB
Here is something that explains why we use <div></div>
so much
Because some developers are lazy and bad at writing semantic HTML (including any automated systems, CMS, website builders, etc.).
It is a lot better now than it used to be, but then most of the web isn’t new, but old. The issue has been referred to as divitis.
The div
element is a generic container with no semantic meaning. It should be used for layout and other non-semantic grouping of elements.
4.4.16 The div element
Authors are strongly encouraged to view the div element as an element of last resort, for when no other element is suitable. Use of more appropriate elements instead of the div element leads to better accessibility for readers and easier maintainability for authors.
The short answer is, because using the div
element for everything is easier than writing proper semantic HTML. And some website layouts are a Russian doll of elements nested inside elements nested inside more elements, ad infinitum.
It’s true you can find 50 div elements nested inside of each other, because a developer thought it would be easier to use a <div></div>
element, and just slap a class into it, and call it good.
Is section the most direct replacement of div?
Hi there!
No, section
is not always the most direct replacement for div
. While both are block-level elements, they serve different semantic purposes.
div
is a generic container used purely for styling or grouping elements without adding meaning.
section
is a semantic element meant to group related content within a document, often with a heading.
If the content has a clear, meaningful grouping, use section
. If it’s just for layout or styling, div
is more appropriate.