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
Fundamentals
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.
Concept
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).
Foundation
📝 Syntax
JavaScript
ariaColCount
Value
A string representing the total number of columns.
Item
Detail
Type
string (e.g. "2", "3")
Reflects
aria-colcount
Applies to
table, grid, treegrid (and related patterns)
Often paired with
aria-rowcount, aria-colindex on cells
Pattern
📋 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.
Cheat Sheet
⚡ Quick Reference
Goal
Code / note
Read
el.ariaColCount
Write
el.ariaColCount = "3"
HTML attribute
aria-colcount="2"
With rows
Also set aria-rowcount when needed
MDN status
Baseline Widely available
Snapshot
🔍 At a Glance
Four facts about Element.ariaColCount.
Kind
get / set
Instance
Type
string
Column total
Reflects
aria-colcount
Attribute
Baseline
widely
Oct 2023+
Hands-On
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"
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)"
});
{
"supported": true,
"tip": "Declare total columns even if not all are in the DOM",
"valueType": "string (not Number)",
"status": "Baseline Widely available (MDN)"
}
How It Works
Update ariaColCount when the logical width of your data set changes (for example columns added or removed in a grid UI).
Applications
🚀 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.
Under the Hood
🔧 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.
Important
📝 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.
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).
BaselineWidely available
Google ChromeSupported (ARIA reflection)
Yes
Microsoft EdgeSupported (ARIA reflection)
Yes
Mozilla FirefoxSupported (ARIA reflection)
Yes
Apple SafariSupported (ARIA reflection)
Yes
OperaFollow Chromium support
Yes
Internet ExplorerNo ariaColCount IDL — use setAttribute
No
ariaColCountBaseline
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.
Wrap Up
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.
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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about ariaColCount
Reflected aria-colcount string for total columns.
5
Core concepts
📄01
Get / set
on Element
Kind
📝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.