3 ms·
How is attr() better than using a css variable?
by pier25 1y ago
How is attr() better than using a css variable?
- Inviz 1y agohmm... where to start? - 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 Just to name a few
- chrisandchris 1y agoBut if you‘re defining the style within the data (the width within the HTML as data attribute), aren‘t you actually mixing presentation with data?
- bawolff 1y agoThey do different things, they aren't really in competition with each other.
- taejavu 1y agoattr() lets you read values from your html in css. CSS variables do not.