HTML - attributes - scope

revision:


Content

"scope" attribute : specifies what type of header a header cell is syntax some examples


"scope" attribute : specifies what type of header a header cell is

top

The scope attribute specifies whether a header cell is a header for a column, row, or group of columns or rows. The scope attribute has no visual effect in ordinary web browsers, but can be used by screen readers.

The scope attribute can be used on the following element: <th>


syntax

top

<th scope="value"></th >

Attribute values:

col specifies that the header cell is used for column;
row specifies that the header cell is used for row;
colgroup specifies that the header cell is used for group of column;
rowgroup specifies that the header cell is used for group of row.


some examples

top
Month Savings
1 January $100
2 January $80
codes:
                    <table style="margin-left:3vw;">
                        <tr>
                        <th></th>
                        <th scope="col">Month</th>
                        <th scope="col">Savings</th>
                        </tr>
                        <tr>
                        <td>1</td>
                        <td>January</td>
                        <td>$100</td>
                        </tr>
                        <tr>
                        <td>2</td>
                        <td>January</td>
                        <td>$80</td>
                        </tr>
                    </table>
                    <style>
                        table, th, td {border: 1px solid black;}
                    </style>  
                
NAME AGE BRANCH
Sophie 22 CSE
Marc 25 EC
codes:
                    <table style="margin-left:3vw;" border="1" width="500">
                        <tr>
                            <th scope="col">NAME</th>
                            <th scope="col">AGE</th>
                            <th scope="col">BRANCH</th>
                        </tr>
                
                        <tr>
                            <td>Sophie</td>
                            <td>22</td>
                            <td>CSE</td>
                        </tr>
                
                        <tr>
                            <td>Marc</td>
                            <td>25</td>
                            <td>EC</td>
                        </tr>
                    </table>