Can some one explain how the content
attribute internally work in the browser. Does it create a new node in the DOM even it is not displayed in the webInspector. And will it have the same influences of memory consumption like a real DOM node?
The content CSS property replaces an element with a generated value. Objects inserted using the content property are anonymous replaced elements.
The content attribute in HTML is used to display the value with the name or http-equiv. It is associated with the <meta> element. The content attribute of the <meta> element is used to set the meta information in an HTML document. This can be the information for the description or the keywords, for name attribute.
CSS [attribute^="value"] Selector The [attribute^="value"] selector is used to select elements with the specified attribute, whose value starts with the specified value. The following example selects all elements with a class attribute value that starts with "top": Note: The value does not have to be a whole word!
The attr() CSS function is used to retrieve the value of an attribute of the selected element and use it in the stylesheet. It can also be used on pseudo-elements, in which case the value of the attribute on the pseudo-element's originating element is returned.
I found this on CSS 2.1 spec
Generated content does not alter the document tree. In particular, it is not fed back to the document language processor (e.g., for reparsing).
From the W3C:
This property (content) is used with the :before and :after pseudo-elements to generate content in a document. Generated content does not alter the document tree. In particular, it is not fed back to the document language processor (e.g., for reparsing).
Also, according to MDN:
Objects inserted using the content property are anonymous replaced elements. In CSS, a replaced element is an element whose representation is outside the scope of CSS. These are kind of external objects whose representation is independant of the CSS. Typical replaced elements are
<image>
,<object>
,<video>
or forms element like<textarea>
,<input>
. Some elements, like<audio>
or<canvas>
are replaced elements only in specific cases. Object inserted using the CSS content properties are anonymous replaced elements. CSS handled 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 like vertical-align.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With