softshipper
softshipper

Reputation: 34061

The section is not for generic purpose

I am trying to understand the purpose of the section and found the following article:

The section element is not a generic container element. Now I know what it says. It says above that it represents a generic section of a document. When people write specifications, sometimes they get vague. It is not a generic container.

When an element is needed only for styling purposes or as a convenience for scripting, things like JavaScript, authors are encouraged to use the div element, which we'll talk about in just a little bit. So a general rule is that the section element is appropriate only if the elements contents would be listed explicitly in the documents outline and that's where it reaches the sweet spot. When you have content that needs to be listed in the document outline but it doesn't meet the standard of being syndicated or pushed apart by itself, then that's when the section element is probably appropriate.

The questions are:

Upvotes: 1

Views: 46

Answers (1)

deceze
deceze

Reputation: 522015

What is a generic container?

An element that can be used as a containing element for any arbitrary content, in any arbitrary context. E.g. div is the most generic container there is, because it does not carry any meaning in itself whatsoever. section does have a specific meaning, so shouldn't be used arbitrarily.

What does he mean with styling purposes or as a convenience for scripting?

When you want to style specific elements or you want to programmatically access specific elements via Javascript, you need some hook for that element. E.g., styling the eighteenth word in this sentence is pretty difficult, but becomes much easier when you <span>wrap</span> it in something. Now you can use span { color: red } or document.getElementsByTagName('span') to do something with that element.

Upvotes: 3

Related Questions