# Typed attr() (attr(data-x type(<length>)))

Status: Chrome 133; Firefox 152 Nightly (flag), Safari Technology Preview 249. Interop 2026 focus area. Not Baseline.  
Source: https://github.com/web-platform-tests/interop/blob/main/2026/README.md and https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/152  
Page: https://designforai.dev/css/typed-attr

`attr()` now works in any property and can parse the attribute as a type (`type(<length>)`, `type(<color>)`, `px`), so markup data like `data-cols="3"` drives layout without inline styles.

## HTML

```html
<div class="fx-062" data-cols="3" data-accent="#ec4899"><span>1</span><span>2</span><span>3</span><span>4</span><span>5</span><span>6</span></div>
```

## CSS

```css
.fx-062 {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(attr(data-cols type(<integer>),2),1fr);
  font-family: system-ui
}
.fx-062 span {
  padding: 12px;
  text-align: center;
  border-radius: 6px;
  background: attr(data-accent type(<color>),#e5e7eb);
  color: #fff
}
```

Fallback: The second argument of attr() is the fallback value used by unsupported browsers (they treat the whole attr() as invalid outside `content`, so also set a plain declaration before it).

## Prompt

Feed layout values from data attributes with typed `attr()`: `repeat(attr(data-cols type(<integer>), 2), 1fr)`, `attr(data-accent type(<color>), gray)`. Always give the fallback argument and a preceding plain declaration, because only Chromium ships it in stable as of 2026-09.
