0

Is there some technical differences between a section, div and an article?

Edit: I am not asking about when you should use it. I am talking about specific technical differences.

Ruslan Plastun
  • 1,985
  • 3
  • 21
  • 48
  • 2
    Possible duplicate of [What is the difference between
    and
    ?](https://stackoverflow.com/questions/6939864/what-is-the-difference-between-section-and-div)
    – DreamTeK Oct 30 '19 at 09:29

2 Answers2

3

Since you are asking for technical, and not semantic differences, here we go:

app
  .querySelectorAll("*")
  .forEach(el => console.log(el.constructor.name));
<div id="app">
  <div></div>
  <section></section>
  <article></article>
</div>

As you can see, div has its own constructor interface, HTMLDivElement, whereas section and article do not have this.

Instead, their constructor comes directly from HTMLElement (which HTMLDivElement inherits from).

By what MDN says, the only actual addition HTMLDivElement receives is a property align (which has been marked obsolete).

Thus, it actually does not have any different or additional properties on top of also being an HTMLElement. Technically, it could now as well be an HTMLElement only, but to keep the web compatible with existing code, the HTMLDivElement interface cannot be removed, as there will be alot of existing code that uses the interface. Removing it would break pages using such code.

connexo
  • 53,704
  • 14
  • 91
  • 128
0

They express different semantics.

Articles are articles. Sections are sections. And divs are generic blocks with no semantics.

The semantics are used by tools like screen readers, search engines, and so on to identify what content is what. It can be used to treat some content as more important that others by a search engine or for navigating around a document by a screen reader.

Ruslan Plastun
  • 1,985
  • 3
  • 21
  • 48
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • So they have no difference technically? No special rules or something like that? – Ruslan Plastun Oct 30 '19 at 11:02
  • @PetroKoval — Different semantics *are* a technical difference. – Quentin Oct 30 '19 at 11:03
  • Sorry, but I am not English native speaker. What do you mean under semantics, except: "human defined rules of where you **should** use them"? – Ruslan Plastun Oct 30 '19 at 11:04
  • @PetroKoval — The semantics are used by tools like screen readers, search engines, and so on to identify what content is what. It can be used to treat some content as more important that others by a search engine or for navigating around a document by a screen reader. – Quentin Oct 30 '19 at 11:07
  • There it is! Thanks, it would be awesome if you paste this in your answer. :) – Ruslan Plastun Oct 30 '19 at 11:08
  • There is also a *real* technical difference, see my answer below https://stackoverflow.com/a/58624781/3744304 – connexo Oct 30 '19 at 14:42