element() CSS Function
The element() function creates a live image from an HTML element on the page, usable as a background. It is only supported in Firefox.
Description
The element() CSS function creates an image from a live HTML element on the page. Whatever the referenced element currently looks like, including its text, images, animations and form controls, is drawn as an <image> that can be used anywhere an image is accepted, such as background-image. If the original element changes, the image updates with it.
The argument is an element ID selector, such as element(#chart). The referenced element does not have to be visible; it can be hidden or placed off-screen, which makes element() useful for reflections, live thumbnails, magnifiers and decorative backgrounds built from HTML content, including a canvas that is being drawn by a script.
element() is only supported in Firefox, and only with the vendor prefix, as -moz-element(). No other browser supports it, so it should only be used as an enhancement with a fallback background.
/* A live reflection of a heading */
.reflection {
height: 60px;
background: #e2e8f0; /* fallback */
background: -moz-element(#title) no-repeat;
transform: scaleY(-1);
opacity: 0.3;
}
/* Use an animated canvas as a background */
.panel {
background-image: -moz-element(#animated-canvas);
}
Syntax
element() = element( <id-selector> )
/* supported form */
-moz-element( <id-selector> )
Values
- <id-selector>An ID selector, such as #source, identifying the element to use as an image. The image updates live whenever that element changes.
Example
Browser Support
The following information will show you the current browser support for the CSS element() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





