HTML Element: section

The HTML section element is quite literally a section of a document. A section, in this context, is a grouping of content that typically contains a heading.

The section element is not a generic container element. It is appropriate to use a section element only if its contents would be listed explicitly in the document’s outline.

Example

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

Syntax

1
<h1>Learning Spanish</h1>
2
    <section>
3
        <h2>First Chapter</h2>
4
        <p>Eiusmod esse amet reprehenderit ea consequat et tempor ad enim.</p>
5
    </section>
6
    <section>
7
        <h2>Second Chapter</h2>
8
        <p>Laborum laborum elit aute reprehenderit ea exercitation cupidatat qui ipsum.</p>
9
    </section>

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.

Related HTML Elements

  • There are several other sectioning elements, useful for splitting up content on a page in a descriptive way: <article>, <aside>, <form>, <header>, <footer>, <main>, and <nav> are all sectioning elements.

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


This content originally appeared on Envato Tuts+ Tutorials and was authored by Andy Leverenz

The HTML section element is quite literally a section of a document. A section, in this context, is a grouping of content that typically contains a heading.

The section element is not a generic container element. It is appropriate to use a section element only if its contents would be listed explicitly in the document’s outline.

Example

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

Syntax

1
<h1>Learning Spanish</h1>
2
    <section>
3
        <h2>First Chapter</h2>
4
        <p>Eiusmod esse amet reprehenderit ea consequat et tempor ad enim.</p>
5
    </section>
6
    <section>
7
        <h2>Second Chapter</h2>
8
        <p>Laborum laborum elit aute reprehenderit ea exercitation cupidatat qui ipsum.</p>
9
    </section>

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.

  • There are several other sectioning elements, useful for splitting up content on a page in a descriptive way: <article>, <aside>, <form>, <header>, <footer>, <main>, and <nav> are all sectioning elements.

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


This content originally appeared on Envato Tuts+ Tutorials and was authored by Andy Leverenz


Print Share Comment Cite Upload Translate Updates
APA

Andy Leverenz | Sciencx (2023-03-20T19:53:54+00:00) HTML Element: section. Retrieved from https://www.scien.cx/2023/03/20/html-element-section/

MLA
" » HTML Element: section." Andy Leverenz | Sciencx - Monday March 20, 2023, https://www.scien.cx/2023/03/20/html-element-section/
HARVARD
Andy Leverenz | Sciencx Monday March 20, 2023 » HTML Element: section., viewed ,<https://www.scien.cx/2023/03/20/html-element-section/>
VANCOUVER
Andy Leverenz | Sciencx - » HTML Element: section. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/03/20/html-element-section/
CHICAGO
" » HTML Element: section." Andy Leverenz | Sciencx - Accessed . https://www.scien.cx/2023/03/20/html-element-section/
IEEE
" » HTML Element: section." Andy Leverenz | Sciencx [Online]. Available: https://www.scien.cx/2023/03/20/html-element-section/. [Accessed: ]
rf:citation
» HTML Element: section | Andy Leverenz | Sciencx | https://www.scien.cx/2023/03/20/html-element-section/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.