Skip to content

[css-images-4] image() function for solid colors needs more thought #2092

Closed
@faceless2

Description

@faceless2

If you're going to allow creation a solid-color image with the new image() function:

div { background: image("missing.png" black) }

You'll have to specify the width and height too; it's required for every situation except the one given in the example, where the image is a background-image and repeating in both axes. A specific example:

#bullet { content: image("missing.png" black); } /* what size is it ? */

In addition, if this functionality exists then it should be a "first class" image type, not just there as a fallback when a image fails to load from a URL. You're not preventing anything with this restriction, just making the CSS unnecessarily more complex:

div { content: image(blue); }   /* what, I can't do this?!?! */
div { content: image("about:invalid", blue); }   /* fine, I'll do this instead */

Finally, while a generated solid-color image is a nice idea for anyone creating test-cases, the apparent goal (preventing background-color leak-through under a translucent background image while still setting a background if the image is missing) is pretty specific and could probably be achieved in an easier way. The example from the current draft:

body      { color: black; background: white; }
p.special { color: white; background: image("dark.png", black); }

could perhaps be achieved with a "final" (or maybe "stop") ident after the last image in the background stack, to prevent the processing of any further layers in the background if it's successfully loaded. So you could do something like this:

body      { color: black; background: white; }
p.special { color: white; background: image("dark.png") final, black); }

Whether that's an improvement or not largely depends on whether there's any other useful purpose for these solid-color images.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions