html tutorial - scope Attribute in HTML - html5 - html code - html form

Learn html - html tutorial - Scope attribute in html - html examples - html programs
- The scope attribute defines whether a header cell is a header for a column, row, or group of columns or rows.
Syntax for scope attribute in HTML:
<th scope =”col|row|colgroup|rowgroup”>content</th>
Applies To:
Element | Attribute |
---|---|
<th> | scope |
scope Attribute Values:
Value | Description |
---|---|
col | Defines that the cell is a header for a column |
row | Defines that the cell is a header for a row |
colgroup | Defines that the cell is a header for a group of columns |
rowgroup | Defines that the cell is a header for a group of rows |
Sample Coding for scope Attribute in HTML:
Tryit<!DOCTYPE html>
<html>
<body>
<table border ="1">
<tr>
<th scope=”col”>Firstname</th>
<th scope=”col”>Lastname</th>
</tr>
<tr>
<td>Wiki</td>
<td>techy</td>
</tr>
<tr>
<td colspan="10">Fullname: Wikitechy</td>
</tr>
</table>
</body>
</html>
Code Explanation for scope Attribute in HTML:

- <table> element - is used to define the data in the table format. border is the attribute that shows border around the table.
- <tr> element – used to represents the row of the table.
- <th> element – used to represents the header of the table.
- scope attribute specifies whether the heading is associated with a row or a column.
Output for scope Attribute in HTML:

- The scope attribute does not have a visual effect in web browsers, but they read by search engines or screen readers.
Browser Support for scope Attribute in HTML:
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
Yes | Yes | Yes | Yes | Yes |