![HTML Tutorial](/html/images/html-mini-logo.jpg)
- HTML Tutorial
- HTML - Home
- HTML - Introduction
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- 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 Color Names & Values
- HTML - Color Names
- 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 Picker
- HTML References
- HTML - Cheat Sheet
- 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 - scope Attribute
HTML scope is an HTML attribute that is used to define the header cell. It is used for the header row, column, colgroup, or rowgroup.
The <th> element specifies a cell as the header of a group of table cells. The scope and headers attributes specify the nature of this group.
Note:This attribute is used by screen readers but has no visible effect on the browser.
If the scope attribute is not defined, then browsers automatically select the group of cells to which the header cell applies.
Syntax
<th scope=" col | row | colgroup | rowgroup " >
- row: The header relates to all cells of the row it belongs to.
- col: The header relates to all cells of the column it belongs to.
- rowgroup: The header belongs to a rowgroup and relates to all of its cells.
- colgroup: The header belongs to a colgroup and relates to all its cells.
Applies on
Below-listed element allows the use of the HTML scope attribute.
Element | Description |
---|---|
<th> | HTML <th> tag designates the header cell for HTML tables. |
Examples of HTML scope attribute
Below examples will illustrate the HTML scope attribute, where and how we should use this attribute!
Using scope='col' and scope='row' in "th" tag
Output window displays a table and scope applied for the 'th' elements are highlighted.
<!DOCTYPE html> <html> <head> <title>HTML th scope Attribute</title> <style> td, th { border: 1px solid rgb(190, 190, 190); padding: 10px; } td { text-align: center; } th[scope='col'] { background-color: #696969; color: #fff; } th[scope='row'] { background-color: #d7d9f2; } </style> </head> <body> <h3>HTML scope attribute in 'th'</h3> <table> <caption>Alien football stars</caption> <tr> <td>S.NO</td> <th scope="col">Player</th> <th scope="col">Gloobles</th> <th scope="col">Za'taak</th> </tr> <tr> <td>1.</td> <th scope="row">TR-7</th> <td>7</td> <td>4,569</td> </tr> <tr> <td>2.</td> <th scope="row">Khiresh Odo</th> <td>7</td> <td>7,223</td> </tr> <tr> <td>3.</td> <th scope="row">Mia Oolong</th> <td>9</td> <td>6,219</td> </tr> </table> </body> </html>
Using scope='colgroup' and scope='rowgroup' in "th" tag
Output window displays a table and scope applied for the 'th' elements are in bold.
<!DOCTYPE html> <html> <head> <title>HTML th scope Attribute</title> </head> <body> <h3>HTML scope attribute in 'th'</h3> <table border="1"> <tr> <th scope="colgroup">Name</th> <th scope="colgroup">Company</th> <th scope="colgroup">Roles</th> </tr> <tr> <th scope="rowgroup">Aman</th> <td>tutorialspoint</td> <td>Technical content Engineer</td> </tr> <tr> <th scope="rowgroup">Vivek</th> <td>tutorialspoint</td> <td>Developer</td> </tr> </table> </body> </html>
Supported Browsers
Attribute | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
scope | Yes | Yes | Yes | Yes | Yes |
html_attributes_reference.htm
Advertisements