JavaScript Element ariaColCount Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

In JavaScript, the ariaColCount property of Element reflects the aria-colcount attribute, which defines the number of columns in a table, grid, or treegrid (MDN). It is most useful when not all columns are present in the DOM.

Read the notes below before you get or set this property. Prefer feature detection when support is limited.

Syntax

Use el.ariaColCount. Start with this line.

JavaScript
el.ariaColCount
CallWhat it does
el.ariaColCountPrimary signature.

Built into the browser. Read or assign el.ariaColCount — no import required.

Library declarations
JavaScript
el.ariaColCount

Parameters

ParameterDescription
Table / grid rootRequired. Where ariaColCount lives
String countRequired. Total columns, or "-1"
ariaColIndexOptional. Maps visible columns to full indices

Return Value

Return ValueDescription
*The current value of el.ariaColCount.

JavaScript Examples

Example 1 — Read ariaColCount

MDN-style table: read the reflected column-count string.

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

How It Works

  1. Select the table. The root that owns aria-colcount.
  2. Read ariaColCount. Returns the reflected string.
  3. Expect text digits. "2", not the number 2.
  4. Meaning. Full table width in columns (may exceed visible cells).

Example 2 — Get and Set (MDN)

Update the total column count from script.

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

How It Works

  1. Log the start value. Matches the HTML attribute.
  2. Assign a string. Prefer "3" over the number 3.
  3. Read again. Confirms the property (and attribute) updated.
  4. Keep indices honest. Update ariaColIndex if visible columns change.

Example 3 — Unknown Total ("-1")

When you know the DOM is incomplete but not the full width, use "-1".

JavaScript
const grid = document.getElementById("big-grid");

// Only some columns are rendered right now…
grid.ariaColCount = "-1";
console.log(grid.ariaColCount); // "-1"

// Later, when the server reports the full width:
grid.ariaColCount = "24";
console.log(grid.ariaColCount); // "24"
Try It Yourself

How It Works

  1. Start incomplete. Set "-1" so AT knows the DOM count may be wrong.
  2. Learn the real total. From your API / data model.
  3. Replace with a number string. e.g. "24".
  4. Still label columns. Use ariaColIndex on visible headers/cells.

Browser Support

Element.ariaColCount is Baseline Widely available (MDN: across browsers since October 2023). It is not Deprecated, Experimental, or Non-standard.

✓ Baseline Widely available

Element.ariaColCount

Reflects aria-colcount as a string. Tell AT the full column total when the DOM shows only a subset.

Baseline Widely available
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Android WebView Supported · Modern WebView
Full support
ariaColCount Baseline

Bottom line: Safe for modern apps. Use string counts, set -1 when unknown, and pair with ariaColIndex for partial column sets.

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 (MDN).
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. Use "-1" when the total is unknown but not all columns are in the DOM.
When not all columns are present in the DOM (virtualized or partially rendered tables). If every column is in the DOM, browsers can usually count them and the attribute is often unnecessary (MDN).
ariaColCount is the total columns; ariaRowCount is the total rows. When only some columns are shown, pair with ariaColIndex so AT knows each column’s position in the full set.
Yes. Reading and writing ariaColCount updates the reflected aria-colcount attribute.

Next: ariaColIndex

Learn the Element property that reflects aria-colindex for a column’s position.

ariaColIndex tutorial →

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.

11 people found this page helpful