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.
degamad|6 months ago
notpushkin|6 months ago
CSS variables are another thing to consider perhaps. You can specify their type explicitly as well (albeit using a more verbose syntax):