<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/container-style-queries-and-advanced-attr-rethinking-how-to-wire-up-my-components-in-css-ithpoince" -->

---
title: Container style queries and advanced attr(): rethinking...
description: An exploration of combining CSS container style queries with the newer advanced attr() capabilities (typed attribute parsing) to build components that adapt...
canonical: https://daily.dev/posts/container-style-queries-and-advanced-attr-rethinking-how-to-wire-up-my-components-in-css-ithpoince
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Container style queries and advanced attr(): rethinking how to wire up my components in CSS | daily.dev
og:description: An exploration of combining CSS container style queries with the newer advanced attr() capabilities (typed attribute parsing) to build components that adapt...
og:url: https://daily.dev/posts/container-style-queries-and-advanced-attr-rethinking-how-to-wire-up-my-components-in-css-ithpoince
og:image: https://api.daily.dev/og/posts/ItHPOInce.png
og:image:alt: Container style queries and advanced attr(): rethinking how to wire up my components in CSS
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Container style queries and advanced attr(): rethinking how to wire up my components in CSS

**[utilitybend](https://daily.dev/sources/utilitybend)** · 14 min read · 0 upvotes · 0 comments

## Summary

An exploration of combining CSS container style queries with the newer advanced attr() capabilities (typed attribute parsing) to build components that adapt purely through CSS, without JavaScript or modifier classes. Demos cover grid layouts driven by data attributes (data-repeat, data-gap, data-minSize), a density controller for card components using custom-ident values and @container style() queries, and a combined example that lets a CMS-driven HTML attribute (data-featured, data-accent) control layout and color via style queries. Browser support notes: container style queries for custom properties have full support; typed attr() with type() shipped in Chrome/Edge 133 (Feb 2025) and Firefox 155, with Safari only in Technology Preview. A fallback pattern using @supports is shown but the author says they'd rather just use the feature directly.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://utilitybend.com/blog/container-style-queries-and-advanced-attr-rethinking-how-to-wire-up-my-components-in-css>

## Questions this post answers

### When did Firefox add support for typed attr() with the type() syntax in CSS?

Firefox added support for typed attr() with type() in version 155. Chrome and Edge shipped this capability earlier, in version 133 back in February 2025. Safari currently only supports it in Technology Preview, not yet in a stable release.

_Track browser rollout of CSS features like typed attr() on daily.dev before committing to them in production._

### Do you need container-type set on a parent element to use CSS container style queries on custom properties?

No, container-type is not required to query custom properties with container style queries. Any parent element automatically acts as a style query container, and the child element looks up the DOM tree to find the nearest ancestor declaring that custom property, unlike container size queries which do require container-type.

_Developers rethinking component architecture with style queries can compare approaches on daily.dev._

### How do you use CSS attr() to pass a number from an HTML attribute into a grid-template-columns repeat() function?

Use attr(data-repeat type(<number>), 3) inside repeat(), which parses the HTML attribute value as an actual number rather than a string, letting it feed directly into functions like repeat(3, 1fr). Changing the data-repeat attribute value in the markup updates the column count with no extra CSS selector needed.

_Anyone modernizing grid layouts with attr() can find more CSS patterns like this on daily.dev._

## Similar posts on daily.dev

- [CSS Container Queries](https://daily.dev/posts/css-container-queries-iq9qajosu) · Flavio Copes · 24 upvotes · 0 comments
- [Container queries in 2026: Powerful, but not a silver bullet](https://daily.dev/posts/container-queries-in-2026-powerful-but-not-a-silver-bullet-zamknhyli) · LogRocket · 7 upvotes · 0 comments
- [Tailwind CSS v4 Container Queries: Modern Responsive Design](https://daily.dev/posts/tailwind-css-v4-container-queries-modern-responsive-design-migt0pf3e) · SitePoint · 2 upvotes · 0 comments
- [Stop Treating CSS Container Queries Like Traditional Media Queries — Smashing Magazine](https://daily.dev/posts/stop-treating-css-container-queries-like-traditional-media-queries-smashing-magazine-opborjqov) · Smashing Magazine · 8 upvotes · 0 comments

---

Tags: [#css](https://daily.dev/tags/css)

[View this post on daily.dev](https://daily.dev/posts/container-style-queries-and-advanced-attr-rethinking-how-to-wire-up-my-components-in-css-ithpoince)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Container style queries and advanced attr(): rethinking how to wire up my components in CSS","url":"https://daily.dev/posts/container-style-queries-and-advanced-attr-rethinking-how-to-wire-up-my-components-in-css-ithpoince","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/container-style-queries-and-advanced-attr-rethinking-how-to-wire-up-my-components-in-css-ithpoince"},"datePublished":"2026-09-20T07:43:28.006Z","dateModified":"2026-09-20T07:44:50.355Z","description":"An exploration of combining CSS container style queries with the newer advanced attr() capabilities (typed attribute parsing) to build components that adapt...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/ee973ff279912559753ea8e7e4da3f2c?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/ee973ff279912559753ea8e7e4da3f2c?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"utilitybend","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"utilitybend","logo":"https://media.daily.dev/image/upload/s--hONVFSz4--/f_auto,q_auto/v1789890196/logos/utilitybend?_a=BAMAMicg0","url":"https://daily.dev/sources/utilitybend"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/container-style-queries-and-advanced-attr-rethinking-how-to-wire-up-my-components-in-css-ithpoince","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"css","timeRequired":"PT14M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"utilitybend","item":"https://daily.dev/sources/utilitybend"},{"@type":"ListItem","position":3,"name":"Container style queries and advanced attr(): rethinking how to wire up my components in CSS"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/container-style-queries-and-advanced-attr-rethinking-how-to-wire-up-my-components-in-css-ithpoince#faq","mainEntity":[{"@type":"Question","name":"When did Firefox add support for typed attr() with the type() syntax in CSS?","acceptedAnswer":{"@type":"Answer","text":"Firefox added support for typed attr() with type() in version 155. Chrome and Edge shipped this capability earlier, in version 133 back in February 2025. Safari currently only supports it in Technology Preview, not yet in a stable release. Track browser rollout of CSS features like typed attr() on daily.dev before committing to them in production."}},{"@type":"Question","name":"Do you need container-type set on a parent element to use CSS container style queries on custom properties?","acceptedAnswer":{"@type":"Answer","text":"No, container-type is not required to query custom properties with container style queries. Any parent element automatically acts as a style query container, and the child element looks up the DOM tree to find the nearest ancestor declaring that custom property, unlike container size queries which do require container-type. Developers rethinking component architecture with style queries can compare approaches on daily.dev."}},{"@type":"Question","name":"How do you use CSS attr() to pass a number from an HTML attribute into a grid-template-columns repeat() function?","acceptedAnswer":{"@type":"Answer","text":"Use attr(data-repeat type(\u003cnumber\u003e), 3) inside repeat(), which parses the HTML attribute value as an actual number rather than a string, letting it feed directly into functions like repeat(3, 1fr). Changing the data-repeat attribute value in the markup updates the column count with no extra CSS selector needed. Anyone modernizing grid layouts with attr() can find more CSS patterns like this on daily.dev."}}]}
```

