HTML axis Attribute

Beginner
⏱️ 4 min read
📚 Updated: Jun 2026
🎯 2 Examples
Tables & A11y

Introduction

The axis attribute is an HTML feature primarily used with the <td> (table data) and <th> (table header) elements to define conceptual categories for cells in a table. This attribute enhances the accessibility and structure of tables, providing valuable information to assistive technologies and users.

What You’ll Learn

01

Category Names

Not row numbers.

02

td / th

Table cells only.

03

headers

Pair with ids.

04

scope

Modern alternative.

05

JavaScript

Set dynamically.

06

Obsolete

HTML5 legacy.

Purpose of axis Attribute

The axis attribute is used to indicate the category of data represented by a cell in a table. It helps in associating table cells with specific conceptual groups, making it easier for screen readers and other assistive technologies to navigate and interpret tabular data in complex, multi-dimensional layouts.

⚠️
Obsolete in HTML5

The axis attribute is not recommended for new projects. Browsers rarely expose it. Use scope, headers, and semantic <th> markup instead.

📝 Syntax

Add axis to a <td> or <th> cell with one or more category names:

axis.html
<th id="category" axis="category">Category</th>
<td headers="category" axis="category">Product 1</td>

Syntax Rules

  • Valid only on <td> and <th> elements.
  • Value is a comma-separated list of category name tokens.
  • Names describe conceptual axes, not numeric row or column positions.
  • Pair with headers and id on header cells for clearer relationships.

💎 Values

The axis attribute accepts a comma-separated list of category names that describe the conceptual group a cell belongs to. For example:

  • Single categoryaxis="category" or axis="value" labels the type of data in that cell.
  • Multiple categoriesaxis="product, item" assigns the cell to more than one conceptual axis.
  • Custom names — Use meaningful tokens such as student_info, region, or quarter that describe your data model.
💡
Not Numerical Indices

Despite older misconceptions, axis values are not row or column numbers. They are descriptive category names defined by the author.

axis-values.html
<th axis="category">Product</th>
<th axis="value">Price</th>
<td axis="product, item">Widget</td>

⚡ Quick Reference

Use CaseExample ValueNotes
Column category headeraxis="category"On <th>
Data cell groupaxis="value"On <td>
Multi-axis cellaxis="region, quarter"Comma-separated
Modern replacementscope="col"Preferred in HTML5
Header associationheaders="id1 id2"Links td to th ids
Applicable elementstd, thTable cells only

Applicable Elements

ElementSupported?Notes
<th>YesHeader cells
<td>YesData cells
<table>NoNot a cell element
<tr>NoApply on individual cells

Examples Gallery

Implementation example with category names and dynamic JavaScript axis.

👀 Live Preview

Simple product table with axis and headers attributes:

CategoryValue
Product 1$10
Product 2$20

Implementation Example

Let’s consider an example of using the axis attribute in an HTML table:

index.html
<table>
  <tr>
    <th id="category" axis="category">Category</th>
    <th id="value" axis="value">Value</th>
  </tr>
  <tr>
    <td headers="category" axis="category">Product 1</td>
    <td headers="value" axis="value">$10</td>
  </tr>
  <tr>
    <td headers="category" axis="category">Product 2</td>
    <td headers="value" axis="value">$20</td>
  </tr>
</table>
Try It Yourself

How It Works

In this example, the <th> elements have axis attributes set to category names that describe their column role. The <td> elements use matching axis values and headers attributes referencing the corresponding header ids.

Dynamic Values with JavaScript

While the axis attribute is primarily static, you can dynamically modify table structures using JavaScript. This can be useful when dealing with dynamic data or user interactions that require altering the table’s accessibility properties. Here’s a basic example:

index.html
<td id="dynamicCell">Apple</td>

<script>
  // Dynamically set the axis attribute for a table cell
  document.getElementById("dynamicCell").axis = "product, item";
</script>
Try It Yourself

How It Works

In this script, the axis attribute of a table cell with the id dynamicCell is dynamically set to "product, item". This can be helpful when modifying table structures based on user inputs or application logic.

♿ Accessibility

  • Prefer scope and headers — Modern accessible tables use scope on <th> and headers on complex cells.
  • Use semantic structure — Wrap headers in <thead>, body rows in <tbody>, and add a <caption>.
  • axis is legacy — Few browsers ever surfaced axis categories to assistive tech; do not rely on it alone.
  • Meaningful header text — Clear column and row labels matter more than axis tokens.
  • Test with screen readers — Verify tables with NVDA, VoiceOver, or JAWS using current HTML5 patterns.

🧠 How axis Works

1

Author defines categories

Assign comma-separated axis names to td and th cells.

Markup
2

Cells share axis names

Related cells use the same category tokens to form conceptual groups.

Grouping
3

User agent may expose groups

In theory, browsers could let users browse cells by axis category.

Legacy
=

Richer table semantics

In practice, use scope and headers for reliable accessibility today.

Browser Support

The axis attribute is recognized in HTML parsers but is obsolete in HTML5 and was never widely implemented by browsers or assistive technologies.

⚠️ HTML4 legacy · Obsolete

Not recommended for new code

Use scope and headers for accessible tables instead.

Legacy Practical support
Google Chrome Parsed, not exposed
Obsolete
Mozilla Firefox Parsed, not exposed
Obsolete
Apple Safari Parsed, not exposed
Obsolete
Microsoft Edge Parsed, not exposed
Obsolete
axis attribute Obsolete

Bottom line: Learn axis for legacy HTML knowledge; build new tables with scope and headers.

💡 Best Practices

✅ Do

  • Use scope="col" or scope="row" on header cells
  • Link complex cells with headers pointing to th ids
  • Add a descriptive <caption> to every data table
  • Use meaningful category names if documenting legacy axis usage
  • Test tables with screen readers using modern markup

❌ Don’t

  • Use axis as row or column index numbers
  • Rely on axis alone for accessibility
  • Add axis to new production projects without scope/headers
  • Assume browsers expose axis categories to users
  • Skip th elements in favor of styled td cells
  • Use the axis attribute to provide additional semantic information to tables, especially when dealing with complex data relationships in legacy documents.
  • Ensure consistency and accuracy when assigning category names to the axis attribute to maintain table structure integrity.
  • Test your tables with assistive technologies to verify that modern attributes like scope and headers enhance accessibility and usability.

Conclusion

The axis attribute is a valuable tool for understanding how HTML tables were designed to support multi-dimensional categorization. By learning how it was intended to work, you gain insight into table accessibility history.

For new projects, prefer scope, headers, semantic <th> cells, and clear captions. These patterns deliver reliable accessibility in today’s browsers.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about axis

Bookmark these before working with HTML tables.

5
Core concepts
📝 02

td / th

Cells only.

Scope
🔗 03

headers

Pair with ids.

Link
⚙️ 04

.axis

Dynamic JS.

Script
⚠️ 05

Obsolete

Use scope.

HTML5

❓ Frequently Asked Questions

It assigns comma-separated category names to table cells so related data can be grouped conceptually for assistive technologies.
<td> and <th> table cell elements.
No. Values are descriptive category names like category or product, item, not numeric indices.
It is obsolete. Use scope on header cells and headers on data cells for accessible tables.
Yes. Assign cellElement.axis = "product, item" at runtime when updating legacy tables dynamically.
scope, headers, proper <th> markup, <caption>, and semantic table structure.

Build accessible HTML tables

Practice the legacy axis attribute and learn modern scope / headers patterns in the Try It editor.

Try table example →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful