abbr

The abbr attribute in HTML provides a way to shorten the text within <th> elements, improving the accessibility of tables. It is especially useful for long phrases, helping screen readers to convey the information more clearly.

abbr attribute

The abbr attribute in HTML is used to define a shortened version of an element's content. It's often applied to <th> (table header) elements to offer a more concise description. This enhances accessibility, particularly for screen readers, by making the content easier to interpret.

Syntax

index.html
<th abbr="text">

Example

Percentage of Market Share
index.html
<table>
  <tr>
    <th abbr="PMS">Percentage of Market Share</th>
    <!-- Other headers -->
  </tr>
  <!-- Table rows and cells -->
</table>

The abbr attribute assists screen readers and other assistive technologies in interpreting table headers more effectively. By using abbreviations like "PMS" instead of the full "Percentage of Market Share," it makes it easier for users to navigate the data. This contributes to improving the accessibility and user-friendliness of web content.

Values

  • text
    • A brief text abbreviation for the <th> element.

Applies To

The abbr attribute can be applied to various HTML elements.

Example

Employee Name Employee Role
John Doe Marketing
Jane Doe Sales Manager
index.html
<table border="1">
  <tr>
    <th attr="Name">Employee Name</th>
    <th attr="Role">Employee Role</th>
  </tr>
  <tr>
    <td>John Doe</td>
    <td>Marketing</td>
  </tr>
  <tr>
    <td>Jane Doe</td>
    <td>Sales Manager</td>
  </tr>
</table>

Conclusion

The abbr attribute in HTML offers a way to provide a shortened version of the content in <th> elements, enhancing accessibility for users, particularly those using screen readers. This helps simplify long table headers, making it easier for users to quickly understand and navigate the data presented in the table.