Home >Web Front-end >CSS Tutorial >Can CSS `content` property insert HTML, not just text?
Question:
Can the CSS content property be used to insert HTML code instead of text as :before or :after content?
.header:before { content: '<a href="#top">Back</a>'; }
Answer:
Unfortunately, this is not possible. According to the CSS 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).
This means that string values for the content property are always treated literally and not interpreted as HTML.
Using the CSS example provided with the HTML code below:
The above is the detailed content of Can CSS `content` property insert HTML, not just text?. For more information, please follow other related articles on the PHP Chinese website!