Can CSS content Property Insert HTML Instead of Text?
The CSS content property is designed to insert text content before or after an element. However, can it be leveraged to insert HTML code instead of pure text?
No, HTML Insertion Not Possible with CSS content
Unfortunately, the CSS content property does not allow for the insertion of HTML code. According to the specification:
"Generated content does not alter the document tree. In particular, it is not fed back to the document language processor (e.g., for reparsing)."
In other words, the content property treats string values literally, regardless of the document language.
Example: No HTML Parsing
Consider this CSS:
.header:before { content: '<a href="#top">Back</a>'; }
When applied to this HTML:
The above is the detailed content of Can CSS `content` Property Insert HTML Elements?. For more information, please follow other related articles on the PHP Chinese website!