JavaScript Element ariaColSpan Property

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline
Instance property

What You’ll Learn

Element.ariaColSpan is an instance property that reflects the aria-colspan attribute. Learn how it declares how many columns a cell or gridcell spans, how it relates to HTML colspan and ariaColIndex, and how to get or set it from JavaScript—with five examples and try-it labs.

01

Kind

Instance property

02

Type

String (integer)

03

Meaning

Columns spanned

04

Reflects

aria-colspan

05

Status

Baseline widely

06

Used on

Cell / gridcell

Introduction

Some table cells stretch across more than one column—like a merged header or a “Spanning” cell. Assistive technologies need that width as part of the grid model.

aria-colspan declares the span count. The DOM property ariaColSpan lets you read and update it from JavaScript.

JavaScript
const el = document.getElementById("spanning-column");
console.log(el.ariaColSpan); // "2"
el.ariaColSpan = "3";
💡
Beginner tip

On a native HTML table, prefer the HTML colspan attribute for layout. Use ariaColSpan for ARIA grids / treegrids, or when you need the reflected ARIA value in script.

Understanding the Property

MDN: the ariaColSpan property of the Element interface reflects the value of the aria-colspan attribute, which defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.

  • Reflected attribute — mirrors aria-colspan.
  • Get / set — readable and writable string integer.
  • Span width — how many columns the cell covers.
  • Baseline — widely available since October 2023 (MDN).

📝 Syntax

JavaScript
ariaColSpan

Value

A string which contains an integer (the number of columns spanned).

ItemDetail
Typestring containing an integer (e.g. "2")
Reflectsaria-colspan
Applies tocell / gridcell (table, grid, treegrid)
HTML cousincolspan on <td> / <th>

📋 Spanning Cell (MDN Shape)

MDN starts with a cell spanning 2 columns, then updates ariaColSpan to "3":

JavaScript
<table>
  <thead>
    <tr>
      <th>Heading 1</th>
      <th>Heading 2</th>
      <th>Heading 3</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td colspan="2" aria-colspan="2" id="spanning-column">Spanning</td>
      <td>One</td>
    </tr>
  </tbody>
</table>

Related: ariaColIndex (starting column) and ariaColCount (total columns).

⚡ Quick Reference

GoalCode / note
Readel.ariaColSpan
Writeel.ariaColSpan = "3"
HTML attributearia-colspan="2"
Native table layoutcolspan="2" on <td>
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.ariaColSpan.

Kind
get / set

Instance

Type
string

Integer text

Reflects
aria-colspan

Attribute

Baseline
widely

Oct 2023+

Examples Gallery

Examples follow MDN Element: ariaColSpan. Labs use a spanning table cell so you can safely read and write the property.

📚 Getting Started

Read the reflected value and follow MDN’s span update.

Example 1 — Read ariaColSpan

Log the span count from a merged cell.

JavaScript
const el = document.getElementById("spanning-column");
console.log(el.ariaColSpan);

// HTML includes: aria-colspan="2"
Try It Yourself

How It Works

The property returns the attribute string. If the attribute is missing, many browsers return null.

Example 2 — MDN Update to "3"

MDN: change the span from 2 to 3.

JavaScript
let el = document.getElementById("spanning-column");
console.log(el.ariaColSpan); // 2
el.ariaColSpan = "3";
console.log(el.ariaColSpan); // 3
Try It Yourself

How It Works

Assigning the property updates the reflected aria-colspan attribute. For native layout, also keep HTML colspan in sync if you rely on it for rendering.

📈 Index Pair, Attribute Sync & Snapshot

Practice pairing with column index and verify reflection.

Example 3 — Pair with ariaColIndex

Declare starting column and how many columns the cell covers.

JavaScript
const cell = document.createElement("td");
cell.setAttribute("role", "cell");
cell.ariaColIndex = "1";
cell.ariaColSpan = "2";
document.body.appendChild(cell);

console.log({
  start: cell.ariaColIndex,
  span: cell.ariaColSpan,
  coversThrough: "columns 1 and 2"
});
Try It Yourself

How It Works

Index is where the cell starts; span is how wide it is. Keep both consistent with ariaColCount on the table/grid.

Example 4 — Property vs getAttribute

Confirm the attribute stays in sync after a write.

JavaScript
const el = document.createElement("td");
el.setAttribute("aria-colspan", "2");
document.body.appendChild(el);

el.ariaColSpan = "4";
console.log({
  fromProperty: el.ariaColSpan,
  fromAttribute: el.getAttribute("aria-colspan"),
  same: el.ariaColSpan === el.getAttribute("aria-colspan")
});
Try It Yourself

How It Works

Prefer ariaColSpan in script; keep the attribute for HTML markup.

Example 5 — Support Snapshot

Feature-detect and remember HTML colspan vs ARIA.

JavaScript
console.log({
  supported: "ariaColSpan" in Element.prototype,
  tip: "Prefer HTML colspan for native tables; ariaColSpan for ARIA grids",
  valueType: "string integer",
  status: "Baseline Widely available (MDN)"
});
Try It Yourself

How It Works

Do not let ARIA span disagree with the visual layout—mismatched spans confuse AT users.

🚀 Common Use Cases

  • Merged cells in ARIA grids and treegrids.
  • Updating span width when a custom grid layout changes.
  • Keeping ARIA in sync with HTML colspan on hybrid tables.
  • Pairing with ariaColIndex for start + width.
  • Keeping script and markup aligned without manual setAttribute.

🔧 How It Works

1

Cell starts at a column

Often described with ariaColIndex.

Start
2

ariaColSpan sets the width

How many columns the cell covers.

Span
3

Visual layout should match

HTML colspan or grid CSS must agree.

UI
4

Assistive tech understands merges

Users hear accurate cell span information.

📝 Notes

Browser Support

Element.ariaColSpan is Baseline Widely available (MDN: across browsers since October 2023). Logos use the shared browser-image-sprite.png sprite from this project.

Baseline Widely available

Element.ariaColSpan

String integer — reflects aria-colspan (columns spanned by a cell).

Baseline Widely available
Google Chrome Supported (ARIA reflection)
Yes
Microsoft Edge Supported (ARIA reflection)
Yes
Mozilla Firefox Supported (ARIA reflection)
Yes
Apple Safari Supported (ARIA reflection)
Yes
Opera Follow Chromium support
Yes
Internet Explorer No ariaColSpan IDL — use setAttribute
No
ariaColSpan Baseline

Bottom line: Use ariaColSpan to get/set aria-colspan. Keep the span aligned with visual layout (HTML colspan or grid CSS). Pair with ariaColIndex and ariaColCount for a complete column model.

Conclusion

ariaColSpan reflects aria-colspan so cells and gridcells can declare how many columns they span. Use string integers, keep visuals in sync, and prefer HTML colspan for simple native tables when that is enough.

Continue with ariaControlsElements, ariaColIndex, EventTarget, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use string integers for the span count
  • Match ARIA span to the visual merge
  • Pair with ariaColIndex when needed
  • Prefer HTML colspan on native tables
  • Stay within ariaColCount bounds

❌ Don’t

  • Leave ARIA span out of sync with layout
  • Treat the value as a Number type in ARIA APIs
  • Span past the declared column total
  • Rebuild native tables with ARIA without need
  • Forget to update span when merges change

Key Takeaways

Knowledge Unlocked

Five things to remember about ariaColSpan

Reflected aria-colspan string for how many columns a cell covers.

5
Core concepts
📝 02

String integer

span count

Type
🔍 03

Cell / gridcell

table / grid

Use
04

Baseline

widely available

Status
🎯 05

vs colspan

HTML for layout

Tip

❓ Frequently Asked Questions

It reflects the aria-colspan attribute as a string integer that defines how many columns a cell or gridcell spans in a table, grid, or treegrid.
No. MDN marks Element.ariaColSpan as Baseline Widely available (since October 2023). It is not Deprecated, Experimental, or Non-standard.
A string that contains an integer (for example "2" or "3"), not a Number type.
On a native <td>/<th>, HTML colspan is the standard way to span columns. aria-colspan / ariaColSpan is the ARIA reflection used especially for ARIA grid/treegrid widgets (and can mirror colspan).
ariaColCount is the total columns. ariaColIndex is a cell’s starting column. ariaColSpan is how many columns that cell covers from that position.
Yes. Reading and writing ariaColSpan updates the reflected aria-colspan attribute.
Did you know?

MDN’s demo sets both HTML colspan="2" and aria-colspan="2" on the same cell—layout via HTML, ARIA reflection via the attribute/property.

Next: Element ariaControlsElements

Learn the reflected aria-controls element-array property for controlled regions.

ariaControlsElements →

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