HTML <section> Tag - GeeksforGeeks (2024)

Last Updated : 27 Aug, 2024

Summarize

Comments

Improve

The Section tag defines the section of documents such as chapters, headers, footers, or any other sections. The section tag divides the content into sections and subsections.

The section tag is used when requirements of two headers or footers or any other section of documents are needed. Section tag grouped the generic block of related contents. The main advantage of the section tag is, it is a semantic element, that describes its meaning to both the browser and the developer.

Note: Section tag is used to distribute the content i.e., it distributes the sections and subsections.

Syntax

<section> Section Contents </section>

Example 1:The implementation of the section tag

HTML
<!DOCTYPE html><html><body> <!-- html section tag is used here --> <section> <h1> Geeksforgeeek: Section 1 </h1> <p> Content of section 1 </p> </section> <section> <h1> GeeksforGeeks: Section 2 </h1> <p> Content of section 2 </p> </section> <section> <h1> GeeksforGeeks: Section 3 </h1> <p> Content of section 3 </p> </section></body></html>

Output:

HTML <section> Tag - GeeksforGeeks (1)

Nested Section tag:

The section tag can be nested. The font size of subsection is smaller than section tag if the text contains the same font property. The subsection tag is used for organizing complex documents. A rule of thumb is that section should logically appear in outline of the document.

Example 2:The implementation of the nested section tag

HTML
<!DOCTYPE html><html lang="en"><head> <title>Document</title> <style> body { text-align: center; } </style></head><body> <!-- html section tag is used here --> <section> <h1 style="color: green;"> Geeksforgeeek: Section 1 </h1> <p> Content of section 1 </p> <section> <h1>Subsection</h1> <h1>Subsection</h1> </section> </section> <section> <h1>GeeksforGeeks: Section 2</h1> <p>Content of section 2</p> <section> <h1>Subsection</h1> <h1>Subsection</h1> </section> </section></body></html>

Output:

HTML <section> Tag - GeeksforGeeks (2)

Supported Browsers:

HTML <section> Tag – FAQs

What is the difference between the <section> and <div> tags?

The <section> tag is a semantic element that should be used for thematically related content, typically accompanied by a heading. The <div> tag is a non-semantic container used purely for grouping content without implying any relationship or meaning.

When should I use the <section> tag versus the <article> tag?

Use the <section> tag for grouping related content under a common theme within a larger piece, like dividing a webpage into sections. The <article> tag is better suited for standalone content that could be distributed independently, like a blog post or news article.

Should every <section> tag have a heading?

Yes, according to best practices, every <section> element should include a heading (<h1> to <h6>). This helps define the purpose of the section and aids screen readers and search engines in understanding the content.

Can I nest multiple <section> tags within each other?

Yes, you can nest <section> tags to create subsections. This is useful when you need to divide content into multiple hierarchical levels, each with its own heading.

Is the <section> tag required in HTML5?

No, the <section> tag is not required, but it is recommended for improving the semantic structure of your content. It’s particularly useful when you want to give structure to long pages with multiple distinct sections.



Please Login to comment...

HTML <section> Tag - GeeksforGeeks (2024)
Top Articles
One-Time Password (OTP) – Guide For ISVs 2023
Lean Thinking and Methods - 5S | US EPA
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
How To Cut Eelgrass Grounded
Pac Man Deviantart
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Dmv In Anoka
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Pixel Combat Unblocked
Umn Biology
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Weekly Math Review Q4 3
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
San Pedro Sula To Miami Google Flights
Selly Medaline
Latest Posts
Article information

Author: Catherine Tremblay

Last Updated:

Views: 6046

Rating: 4.7 / 5 (67 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Catherine Tremblay

Birthday: 1999-09-23

Address: Suite 461 73643 Sherril Loaf, Dickinsonland, AZ 47941-2379

Phone: +2678139151039

Job: International Administration Supervisor

Hobby: Dowsing, Snowboarding, Rowing, Beekeeping, Calligraphy, Shooting, Air sports

Introduction: My name is Catherine Tremblay, I am a precious, perfect, tasty, enthusiastic, inexpensive, vast, kind person who loves writing and wants to share my knowledge and understanding with you.