- HTML Tutorial
- HTML - Home
- HTML - History and Evolution
- HTML - Overview
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Headings
- HTML - Paragraphs
- HTML - Quotations
- HTML - Comments
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Style Sheet
- HTML - CSS Classes
- HTML - CSS IDs
- HTML - Images
- HTML - Image Map
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Iframes
- HTML - Blocks
- HTML Backgrounds
- HTML - Backgrounds
- HTML Colors
- HTML - Colors
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Code Builder
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - <section> Tag
The HTML <section> tag is used to represent the generic standalone section for the HTML document. The sections should always have a heading, with very few exceptions.
As we mentioned above the section element is a general sectioning element, so it should only be used if there are no more specific elements present.
For example, a navigation menu should be wrapped in a <nav> tag, but a list of search results or a map display and its controls don't have any specific elements, and these all can be placed in a section.
Syntax
Following is the syntax of the <section> tag −
<section>.....</section>
Example
The following program shows the usage the HTML <section> tag.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML section tag</title> </head> <body> <p>Example of the HTML 'section' element</p> <!--create a section element--> <section> <h2>HTML</h2> <p>Hyper Text Markup Language</p> </section> </body> </html>
When we run the above code, it will generate an output consisting of the text displayed on the webpage.
Example
Consider the following example, where we are going to use the <section> tag and applying the CSS properties.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML section tag</title> <style> section { width: 300px; height: 100px; background-color: blueviolet; color: white; border-radius: 10px; } section>h2, p { margin: 20px 10px; } </style> </head> <body> <p>Example of the HTML 'section' element</p> <!--create a section element--> <section> <h2>HTML</h2> <p>The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser</p> </section> </body> </html>
On running the above code, the output window will pop up, consisting of the text along with a CSS applied to it is displayed on the webpage.
Example
Let's look into the another scenario, where we are going to create a multiple section.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML section tag</title> <style> section { width: 300px; height: 100px; background-color: rgb(94, 16, 168); color: white; border-radius: 10px; } section>h2, p { margin: 20px 10px; } </style> </head> <body> <p>Example of the HTML 'section' element</p> <!--create a section element--> <section> <h2>HTML(section1)</h2> <p>HyperText Markup Language.</p> </section> <section> <h2>CSS(section2)</h2> <p>Cascading Style Sheet</p> </section> <section> <h2>JS(section3)</h2> <p>JavaScript</p> </section> </body> </html>
When we run the above code, it will generate an output displaying the different sections text along with the CSS applied on the webpage.
Example
In the following example, we are going to use the section with the button and the anchor link.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML section tag</title> <style> section { width: 300px; height: 100px; background-color: rgb(6, 164, 30); color: white; border-radius: 10px; } section>h2, p { margin: 20px 10px; } </style> </head> <body> <!--create section element--> <section> <h1>Links section</h1> <a href="">Home</a> <a href="">About</a> <a href="">ContantUs</a> </section> <section> <h1>Buttons section</h1> <button>Create</button> <button>View</button> <button>Delete</button> </section> </body> </html>
When we run the above code, it will generate an output displaying the buttons and the links on the webpage.