More on Tables

 



Adding a Caption

  • To add a title to your table, you can use the <caption> element. This element helps both in terms of SEO and accessibility.

<table>
  <caption>Student Details</caption>
     <!-- Rest of the table here -->
</table>

Table Headers and Footers

  • Besides <th> for individual header cells, HTML tables allow you to group header or footer content using <thead> and <tfoot>.

<table>
  <thead>
     <!--  header content -->
  </thead>
  <tfoot>
  <!-- footer content -->
  </tfoot>
  <tbody>
  <!-- body content -->
  </tbody>
</table>

Column Groups

  • You can use the <colgroup> and <col> elements to apply styles to an entire column in an HTML table.

<table>
  <colgroup>
    <col style="background-color:yellow">
  </colgroup>
  <!-- rest of the table -->
</table>

Accessibility in Tables

  • To make your tables more accessible, you can use the scope attribute in <th> elements to specify if they are headers for columns, rows, or groups of columns or rows.


<th scope="col">Name</th>
<th scope="col">Age</th>

Related Posts:

  • Anchor Tag <a> tag defines a hyperlink, which is used to link from one page to another page.Key Characteristics of HTML Anchor LinksSpecified by the … Read More
  • HTML Page Structure Understanding the Structure of an HTML Document <!DOCTYPE html> // let browser know it's an HTML5 Document.<html> // Root of an… Read More
  • Paragraph Horizontal and Line Break Tags The <p> tag defines a paragraph.Browsers automatically add a single blank line before and after each.<p>This is a paragraph.</p&g… Read More
  • HTML Attributes What is an HTML Attribute?HTML attributes provide additional information about HTML elements. Attributes are always specified in the start … Read More
  • HTML Comments it is used to understand the code written by someone.the browser will ignore the comments Types of Comments in HTMLSingle-line CommentsSing… Read More

0 Comments:

Post a Comment

Do leave your comments