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
Coding Challenge #45 - Port Scanner
Notice :: WEBTOON
Algebra Calculator Mathway
Byrn Funeral Home Mayfield Kentucky Obituaries
Chalupp's Pizza Taos Menu
United Dual Complete Providers
Zachary Zulock Linkedin
Ohiohealth Esource Employee Login
Sotyktu Pronounce
Healing Guide Dragonflight 10.2.7 Wow Warring Dueling Guide
Nyuonsite
Define Percosivism
Simpsons Tapped Out Road To Riches
NBA 2k23 MyTEAM guide: Every Trophy Case Agenda for all 30 teams
My Homework Lesson 11 Volume Of Composite Figures Answer Key
I Saysopensesame
A Person That Creates Movie Basis Figgerits
Talkstreamlive
Breckiehill Shower Cucumber
Jayme's Upscale Resale Abilene Photos
Preggophili
TMO GRC Fortworth TX | T-Mobile Community
Login.castlebranch.com
Penn State Service Management
Craigslist Boerne Tx
Housing Intranet Unt
Otis Inmate Locator
Nurtsug
Indiana Jones 5 Showtimes Near Jamaica Multiplex Cinemas
How to Draw a Bubble Letter M in 5 Easy Steps
What Time Does Walmart Auto Center Open
The Pretty Kitty Tanglewood
Diana Lolalytics
What Time Is First Light Tomorrow Morning
New Gold Lee
Mohave County Jobs Craigslist
Is The Nun Based On a True Story?
Immobiliare di Felice| Appartamento | Appartamento in vendita Porto San
QVC hosts Carolyn Gracie, Dan Hughes among 400 laid off by network's parent company
Todd Gutner Salary
Craigslist Com St Cloud Mn
Login
4k Movie, Streaming, Blu-Ray Disc, and Home Theater Product Reviews & News
Matt Brickman Wikipedia
Zeeks Pizza Calories
Bank Of America Appointments Near Me
Dayton Overdrive
Craigslist Marshfield Mo
Makemkv Key April 2023
A Snowy Day In Oakland Showtimes Near Maya Pittsburg Cinemas
Jasgotgass2
Bob Wright Yukon Accident
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.