Skip to content

[css-values-5] attr()'s "px"/etc keywords #11034

@tabatkins

Description

@tabatkins

In #10437 (comment) we resolved to change attr()'s type argument from a bespoke list of keywords to the newly-minted "CSS grammar in CSS" syntax.

Most of the existing attr() type keywords translate over just fine (usually just wrapping them in <> characters), but the unit names don't. That is, under the current spec you can write width: attr(foo px), and given an element like <div foo=500>, it'll be parsed as a number and then be assumed to be a px value. There's no way to express this sort of behavior in CSS grammar, tho.

Note that this is basically just a convenience; one could instead write calc(1px * attr(foo <number>)) and get the same result. So the use-case is covered no matter what.

Do we want to try and allow this, tho? The issue is that bare keywords already have meaning in the <css-syntax> production (they represent those keywords, same as in any other CSS grammar), so it would be somewhat awkward to mix them in.

I propose that we just drop that functionality, and let calc() cover the issue of "interpret a number as a particular unit".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions