Skip to content

CSS element() #1451

Open
Open

Description

@BearCooder

Description

I propose an investigation of CSS element() which lets a page use the appearance of one element as an image elsewhere on the same page. The first target would be backgrounds that follow changes to their source, such as a small page preview or a canvas used in several places.

The investigation would establish a useful, clearly specified subset and build tests that browser teams can share. It would cover simple sources, live updates, image size, missing references, and reference loops.

Specification and existing tests

The current directory listing has no dedicated element/ suite. The first task would include checking for relevant tests elsewhere before adding new ones.

Rationale

Reasons for including the feature

There are concrete examples of developers using this kind of visual reuse:

  • A page minimap. The earlier proposal discussion reports its use on Stefan Judis's site.
  • Canvas output used as CSS images. The CSS Paint polyfill README documents using -moz-element() and -webkit-canvas() in some browsers, with canvas encoding through toDataURL() or toBlob() in others. That is a concrete example of a library needing different paths for similar work.
  • Developer interest. Comments on the earlier proposal express interest in the feature. This is useful qualitative evidence, but it is not a representative survey or a usage estimate.
  • A known test gap. The 2024 rejection identifies an actionable obstacle. An investigation can address that obstacle with a small, reviewed suite instead of repeating a broad implementation request.

Activity

  1. added
    investigation-effort-proposal
    on Sep 23, 2026
  2. thebabydino commented on Sep 24, 2026

    @thebabydino

    The below is an example of something that's not possible without it. This is almost pure CSS with the except of the alpha fade grain effect, which uses a super simple SVG filter.

    Animated GIF. Shows a 5 point star with a grainy fade inner glow that's a checkered pattern. On hover, the glow intensifies, both in terms of alpha and in terms of how far it extends inwards. The checkered pattern also animates.
  3. Opisek commented on Nov 15, 2026

    @Opisek

    Chiming in to say I would absolutely love this feature for providing previews of elements in other parts of the website.

    I have already written a more detailed report of my testing with the experimental version of this feature in Firefox:

    web-platform-dx/developer-signals#297

    One issue I'd like to bring up (already described in the link above) is that there is no native CSS way to mirror the width and height of the referenced element, so if you want a "copy" of another part of DOM to have the same size, you either have to hard-code the values or use JavaScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    investigation-effort-proposal

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions