JavaScript Element ariaColCount Property

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

What You’ll Learn

Element.ariaColCount is an instance property that reflects the aria-colcount attribute. Learn how it declares the total number of columns in a table, grid, or treegrid, when it matters for partial DOM tables, and how to get or set it from JavaScript—with five examples and try-it labs.

01

Kind

Instance property

02

Type

String

03

Meaning

Total column count

04

Reflects

aria-colcount

05

Status

Baseline widely

06

Used on

Table / grid / treegrid

Introduction

Assistive technologies need to know how wide a data table or grid is—even when only some columns are rendered in the DOM (virtualized or paged columns).

aria-colcount declares that total. The DOM property ariaColCount lets you read and update it from JavaScript.

JavaScript
const el = document.getElementById("semantic-table");
console.log(el.ariaColCount); // "2"
el.ariaColCount = "3";
💡
Beginner tip

The value is a string (for example "3"), not a Number. Pair it with aria-rowcount when you also declare total rows.

Understanding the Property

MDN: the ariaColCount property of the Element interface reflects the value of the aria-colcount attribute, which defines the number of columns in a table, grid, or treegrid.

  • Reflected attribute — mirrors aria-colcount.
  • Get / set — readable and writable string.
  • Total columns — may be larger than columns currently in the DOM.
  • Baseline — widely available since October 2023 (MDN).

📝 Syntax

JavaScript
ariaColCount

Value

A string representing the total number of columns.

ItemDetail
Typestring (e.g. "2", "3")
Reflectsaria-colcount
Applies totable, grid, treegrid (and related patterns)
Often paired witharia-rowcount, aria-colindex on cells

📋 Semantic Table (MDN Shape)

MDN sets aria-colcount="2" on a table (with aria-rowcount="100"), then updates the column count to "3" via the property:

JavaScript
<table
  id="semantic-table"
  role="table"
  aria-label="Semantic Elements"
  aria-rowcount="100"
  aria-colcount="2">
  <caption>Semantic Elements to use instead of ARIA's roles</caption>
  <thead role="rowgroup">
    <tr role="row">
      <th role="columnheader">ARIA Role</th>
      <th role="columnheader">Semantic Element</th>
    </tr>
  </thead>
  <tbody role="rowgroup">
    <tr role="row">
      <td role="cell">header</td>
      <td role="cell">h1</td>
    </tr>
  </tbody>
</table>

Prefer a real <table> with semantic headers when you can. Use ARIA column counts when you need to describe a larger logical grid than what is currently rendered.

⚡ Quick Reference

GoalCode / note
Readel.ariaColCount
Writeel.ariaColCount = "3"
HTML attributearia-colcount="2"
With rowsAlso set aria-rowcount when needed
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.ariaColCount.

Kind
get / set

Instance

Type
string

Column total

Reflects
aria-colcount

Attribute

Baseline
widely

Oct 2023+

Examples Gallery

Examples follow MDN Element: ariaColCount. Labs use a small table so you can safely read and write the property.

📚 Getting Started

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

Example 1 — Read ariaColCount

Log the column count from a table.

JavaScript
const el = document.getElementById("semantic-table");
console.log(el.ariaColCount);

// HTML includes: aria-colcount="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 column count from 2 to 3.

JavaScript
let el = document.getElementById("semantic-table");
console.log(el.ariaColCount); // 2
el.ariaColCount = "3";
console.log(el.ariaColCount); // 3
Try It Yourself

How It Works

Assigning the property updates the reflected aria-colcount attribute. Keep the count consistent with your real (or logical) column set.

📈 Row Pair, Attribute Sync & Snapshot

Practice pairing with row count and verify reflection.

Example 3 — Pair with aria-rowcount

Declare both total columns and total rows on a table.

JavaScript
const table = document.createElement("table");
table.setAttribute("role", "table");
table.setAttribute("aria-rowcount", "100");
table.ariaColCount = "4";
document.body.appendChild(table);

console.log({
  ariaColCount: table.ariaColCount,
  ariaRowCount: table.getAttribute("aria-rowcount")
});
Try It Yourself

How It Works

MDN’s example uses both attributes together so AT knows the full logical size of the data set.

Example 4 — Property vs getAttribute

Confirm the attribute stays in sync after a write.

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

el.ariaColCount = "5";
console.log({
  fromProperty: el.ariaColCount,
  fromAttribute: el.getAttribute("aria-colcount"),
  same: el.ariaColCount === el.getAttribute("aria-colcount")
});
Try It Yourself

How It Works

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

Example 5 — Support Snapshot

Feature-detect and remember when column count helps.

JavaScript
console.log({
  supported: "ariaColCount" in Element.prototype,
  tip: "Declare total columns even if not all are in the DOM",
  valueType: "string (not Number)",
  status: "Baseline Widely available (MDN)"
});
Try It Yourself

How It Works

Update ariaColCount when the logical width of your data set changes (for example columns added or removed in a grid UI).

🚀 Common Use Cases

  • Data tables that expose a total column count to AT.
  • Virtualized grids where only some columns are rendered.
  • Treegrids and spreadsheet-like widgets with dynamic columns.
  • Keeping script and markup aligned without manual setAttribute.
  • Pairing with aria-rowcount for full table dimensions.

🔧 How It Works

1

Table / grid has a logical width

You know the total number of columns in the data set.

Model
2

Set aria-colcount / ariaColCount

Expose that total as a string on the container.

Declare
3

DOM may show fewer columns

Virtualized UIs still report the full count.

Partial DOM
4

Assistive tech understands size

Users get accurate table/grid dimensions.

📝 Notes

  • Not Deprecated, Experimental, or Non-standard on MDN (Baseline Widely available).
  • Value is a string representing the column count.
  • Often used with aria-rowcount and cell aria-colindex.
  • Related: ariaColIndex, ariaChecked, EventTarget, JavaScript hub.

Browser Support

Element.ariaColCount 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.ariaColCount

String — reflects aria-colcount (total columns in table/grid/treegrid).

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 ariaColCount IDL — use setAttribute
No
ariaColCount Baseline

Bottom line: Use ariaColCount to get/set aria-colcount. Keep the string count aligned with your logical column set, especially for virtualized tables. Pair with aria-rowcount when you also declare total rows.

Conclusion

ariaColCount reflects aria-colcount so tables, grids, and treegrids can declare their total column count as a string—even when not every column is in the DOM. Update it from JavaScript when the logical width of your data changes.

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

💡 Best Practices

✅ Do

  • Use a string count that matches the logical column total
  • Pair with aria-rowcount when declaring full size
  • Prefer semantic <table> markup when possible
  • Update the count when columns are added or removed
  • Use cell indexes when only a subset of columns is shown

❌ Don’t

  • Leave a stale count after the grid width changes
  • Treat the value as a Number type in APIs that expect strings
  • Invent ARIA tables when a native table is enough
  • Mismatch visible headers vs declared column count without reason
  • Forget accessible names / captions on complex tables

Key Takeaways

Knowledge Unlocked

Five things to remember about ariaColCount

Reflected aria-colcount string for total columns.

5
Core concepts
📝 02

String count

total columns

Type
🔍 03

Table / grid

treegrid too

Use
04

Baseline

widely available

Status
🎯 05

Partial DOM

still declare total

Tip

❓ Frequently Asked Questions

It reflects the aria-colcount attribute as a string that defines the total number of columns in a table, grid, or treegrid.
No. MDN marks Element.ariaColCount as Baseline Widely available (since October 2023). It is not Deprecated, Experimental, or Non-standard.
A string representing the column count (for example "2" or "3"), not a Number type.
When the full column set is not all in the DOM at once (for example a virtualized or partially rendered table), so assistive technologies still know the total column count.
aria-colcount is the total columns; aria-rowcount is the total rows. MDN’s example sets both on the same table.
Yes. Reading and writing ariaColCount updates the reflected aria-colcount attribute.
Did you know?

MDN’s sample table sets aria-rowcount="100" while only showing a few rows—the same idea as aria-colcount: tell AT the full size even when the DOM shows a slice.

Next: Element ariaColIndex

Learn the reflected aria-colindex property for 1-based column positions.

ariaColIndex →

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