Skip to content

Remove the "content" requirement for ::before and ::after? [css-pseudo] #3419

@Pomax

Description

@Pomax

The draft spec for CSS4 pseudo-selectors still state that ::before and ::after must have a content property with a value that is not none, and while this might have made sense back in 2011, this seems a very strange requirement to preserve. Especially given that user-select: none now exists, and ::before/::after no longer need to be used as a hack to inject unselectable text anymore, it seems very odd to still require that content property.

Something like the following CSS should, reasonably speaking, "just work":

div.someclass {
  /* some styling */
}

div.someclass::before {
  width: 1em;
  height: 1em;
  border-radius: 1em;
  background: url(...), papayawhip;
}

The fact that content: " "; is still necessary in a new CSS revision seems a missed opportunity to streamline some quirks. Can https://drafts.csswg.org/css-pseudo-4/#generated-content be changed to finally make content as optional as any other CSS property?

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