In CSS, a replaced element is an element whose representation is outside the scope of CSS. In other words, these are external objects whose representation is independent of the CSS formatting model.
Replaced elements
Typical replaced elements are:
Some elements are treated as replaced elements only in specific cases:
Some form controls can also be replaced elements. The HTML spec says that an <input>
element can be replaced, and <input>
elements of the image type must always be replaced.
Objects inserted using the CSS content
property are anonymous replaced elements. They are "anonymous" because they don't exist in the HTML markup.
Using CSS with replaced elements
CSS handles replaced elements specifically in some cases, like when calculating margins and some auto
values.
Note that some replaced elements, but not all, have intrinsic dimensions or a defined baseline, which is used by some CSS properties, such as vertical-align
.
See also
- HTML Spec https://html.spec.whatwg.org/multipage/rendering.html#replaced-elements
- CSS Key Concepts: CSS syntax, at-rule, comments, specificity and inheritance, the box, layout modes and visual formatting models, and margin collapsing, or the initial, computed, resolved, specified, used, and actual values. Definitions of value syntax, shorthand properties and replaced elements.