X

Headline

This is an important message requiring you to make a choice if you're based in the EU.

HTML <section> Tag

HTML <section> is one of the HTML5 elements. It is used to create standalone sections within a webpage containing logically connected content (news block, contact information etc.). The <section> tag is often used when creating a landing page to divide the page into separate logical blocks.

The <section> tag can be nested within the <article> tag, dividing the content into groups. Therefore, it is required to use <h1> -<h6> headings within the <article> and the <section> tags. It is allowed to use <h2> title in each section, defined with the <section> tag.

Don’t use the <section> tag as a universal container for creating page structure; you should use the <div> tag for that purpose.

Syntax

The element content is written between the opening (<section>) and closing (</section>) tags. The closing tag is required.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Using the section tag</title>
  </head>
  <body>
    <section>
      <h2>Hypertext markup language HTML</h2>
      <p>HTML is the standard markup language for creating web pages and web applications. Browsers receive HTML documents from a web server or from local storage and render the documents into multimedia web pages. HTML describes the structure of a web page semantically and originally included cues for the appearance of the document.</p>
    </section>
    <section>
      <h2>CSS</h2>
      <p>Formal language, which is used as a description zone, formatting the appearance of a web page, written by the help of markup languages HTML and XHTML, but it can be applied to any XML-document, for example, to SVG or XUL.</p>
    </section>
  </body>
</html>

Result

Attributes

The <section> tag supports the the Global Attributes and the Event Attributes.

How to style <section> tag

Common properties to alter the visual weight/emphasis/size of text in <section> tag:?

  • CSS font-style property sets the style of the font. normal | italic | oblique | initial | inherit
  • CSS font-family property specifies a prioritized list of one or more font family names and/or generic family names for the selected element.
  • CSS font-size property sets the size of the font.
  • CSS font-weight property defines whether the font should be bold or thick. CSS text-transform Property controls text case and capitalization.
  • CSS text-decoration property specifies the decoration added to text, and is a shorthand property for text-decoration-line, text-decoration-color, text-decoration-style

Coloring text in <section> tag:

  • CSS color property describes the color of the text content and text decorations
  • CSS background-color property sets the background color of an element.

Text layout styles for <section> tag:

  • CSS text-indent property specifies the indentation of the first line in a text block.
  • CSS text-overflow property specifies how overflowed content that is not displayed should be signaled to the user.
  • CSS white-space property specifies how white-space inside an element is handled.
  • CSS word-break property specifies where the lines should be broken.

Other properties worth looking at for <section> tag


Browser support

6+ 4+ 5+ 11.1+


Do you find this helpful?

Related articles