Web Platform Atlas
EN⚡RUUA⚡DE⚡FR⚡ES⚡PL⚡PT⚡ZH⚡JA⚡
Каталог / HTML / The section element

4.3.3 The section element

Статический предпросмотр (RU): для MDN, WPT, глоссария и BYOK-перевода откройте интерактивный Атлас.
⚡ Открыть главу в Атласе

4.3.3 The section element

Категории:

потоковое содержимое.

Sectioning content.

Palpable content.

Контексты, в которых может использоваться этот элемент:

Where sectioning content is expected.

Контентная модель:

потоковое содержимое.

Опущение тегов в text/html:

Ни один из тегов не может быть опущен.

Атрибуты контента:

глобальные атрибуты

Специфика доступности:

Для авторов.

Для разработчиков.

Санитизация:

Default.

DOM-интерфейс:

Uses HTMLElement.

The section element represents a generic section of a document or application. A section, in this context, is a thematic grouping of content, typically with a heading.

Examples of sections would be chapters, the various tabbed pages in a tabbed dialog box, or the numbered sections of a thesis. A web site's home page could be split into sections for an introduction, news items, and contact information.

Authors are encouraged to use the article element instead of the section element when it would make sense to syndicate the contents of the element.

The section element is not a generic container element. When an element is needed only for styling purposes or as a convenience for scripting, authors are encouraged to use the div element instead. A general rule is that the section element is appropriate only if the element's contents would be listed explicitly in the document's outline.

In the following example, we see an article (part of a larger web page) about apples, containing two short sections.

<article> <hgroup> <h2>Apples</h2> <p>Tasty, delicious fruit!</p> </hgroup> <p>The apple is the pomaceous fruit of the apple tree.</p> <section> <h3>Red Delicious</h3> <p>These bright red apples are the most common found in many supermarkets.</p> </section> <section> <h3>Granny Smith</h3> <p>These juicy, green apples make a great filling for apple pies.</p> </section> </article>

Here is a graduation programme with two sections, one for the list of people graduating, and one for the description of the ceremony. (The markup in this example features an uncommon style sometimes used to minimize the amount of inter-element whitespace.)

<!DOCTYPE Html> <Html Lang=En ><Head ><Title >Graduation Ceremony Summer 2022</Title ></Head ><Body ><H1 >Graduation</H1 ><Section ><H2 >Ceremony</H2 ><P >Opening Procession</P ><P >Speech by Valedictorian</P ><P >Speech by Class President</P ><P >Presentation of Diplomas</P ><P >Closing Speech by Headmaster</P ></Section ><Section ><H2 >Graduates</H2 ><Ul ><Li >Molly Carpenter</Li ><Li >Anastasia Luccio</Li ><Li >Ebenezar McCoy</Li ><Li >Karrin Murphy</Li ><Li >Thomas Raith</Li ><Li >Susan Rodriguez</Li ></Ul ></Section ></Body ></Html>

In this example, a book author has marked up some sections as chapters and some as appendices, and uses CSS to style the headers in these two classes of section differently.

<style> section { border: double medium; margin: 2em; } section.chapter h2 { font: 2em Roboto, Helvetica Neue, sans-serif; } section.appendix h2 { font: small-caps 2em Roboto, Helvetica Neue, sans-serif; } </style> <header> <hgroup> <h1>My Book</h1> <p>A sample with not much content</p> </hgroup> <p><small>Published by Dummy Publicorp Ltd.</small></p> </header> <section class="chapter"> <h2>My First Chapter</h2> <p>This is the first of my chapters. It doesn't say much.</p> <p>But it has two paragraphs!</p> </section> <section class="chapter"> <h2>It Continues: The Second Chapter</h2> <p>Bla dee bla, dee bla dee bla. Boom.</p> </section> <section class="chapter"> <h2>Chapter Three: A Further Example</h2> <p>It's not like a battle between brightness and earthtones would go unnoticed.</p> <p>But it might ruin my story.</p> </section> <section class="appendix"> <h2>Appendix A: Overview of Examples</h2> <p>These are demonstrations.</p> </section> <section class="appendix"> <h2>Appendix B: Some Closing Remarks</h2> <p>Hopefully this long example shows that you <em>can</em> style sections, so long as they are used to indicate actual sections.</p> </section>