HTML Element: section

Example

Here’s a document, which itself has a heading, along with two section elements and their own content:

Syntax

1

Learning Spanish

2
3

First Chapter

4

Eiusmod esse amet reprehenderit ea consequat et tempor ad enim.

5
6
7

Second Chapter

8

Laborum laborum elit aute reprehenderit ea exercitation cupidatat qui ipsum.

9

Result

Document Outline

If we run the above HTML through an HTML outliner tool we can see how the browser interprets the hierarchy:

html document outline examplehtml document outline examplehtml document outline example

The h1 and h2 elements by themselves create this document structure. But even if we’d used only h1 headings, the section elements communicate this hierarchy too.

Browser Support

The section element is supported in all modern browsers. Read more on caniuse.com.

Attributes

A section element supports Global Attributes in HTML. Global Attributes are common to all HTML elements and can be used on all of them (though they may not have much of an effect on some of them).

Content

The HTML section element supports flow content.

What’s the Difference Between a div and a section Element?

Like a div, a section element divides part of an HTML page. The core difference is that a div element is neutral, whereas the section element is not. In other words, a div does not describe the content it contains, while a section element does.

You might use a div element purely for styling purposes, but a section is semantic and says to search engines, browsers, and assistive technologies: “this is a specific chunk of content”.

Learn More

Source