Unfortunately it's not widely available yet. [1] If it was supported by all majors browsers it would be nice for that one project I have that still generates a .html bar chart using style="height: ${height}px;".
I can't wait for someone to make a CSS style sheet that lets you specify all properties through HTML attributes as if CSS was never invented and we were still using good old <font size=2> just with all the styling additions since then.
Browser bugs are so cute. Just sitting there for decades, comments accreted over time. Tasks spinning for eternity. These are truly the cicadas of bugs.
Because HTML attributes are inherently stringly typed. Where CSS can propagate types, it’s because the CSS parser and object model are involved. For that to work with attr() would almost certainly involve extending that machinery into all aspects of the HTML spec, and then all that machinery too. Which is probably impractical for more reasons than I can think of, but I can think of several.
- Variables cascade and cause restyle of whole sub-tree.
- Attributes often are already on the html element, e.g. title, aria, data attributes, so dont need inline styles
- Not mixing data with presentation
[1] https://caniuse.com/mdn-css_types_attr_type-or-unit
Browser bugs are so cute. Just sitting there for decades, comments accreted over time. Tasks spinning for eternity. These are truly the cicadas of bugs.