Skip to content

[css-values] Add valid-empty-like value (for CSS Custom Properties) #10441

@raphaelokon

Description

@raphaelokon

There was a brief conversation (I think between @kizu and @andruud) I participated during CSS Day regarding a declarative keyword to mark the guaranteed absence of a value for a custom property to avoid the space toggle hack, e.g.

.meow {
  --foo: ; /* <- One whitespace character here. */

  color: var(--foo, hotpink) /* Resolves to `--foo` */
}

would become →

.meow {
  --foo: valid-empty; /* <- Explicitly mark missing value as valid. */
  
  color: var(--foo, hotpink) /* Resolves to `--foo` */
}

I think that the inline conditional or if() spec #10064 by @LeaVerou (which was just marked as resolved 🎉) may fix a lot of use-cases around this, but there maybe still be use-cases for a declarative empty value.

EDIT: Change the semantic of the keyword and make it less generic by naming it valid-empty re comment.

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