1

Anonymous replaced elements are content used with :before or :after

See https://developer.mozilla.org/en-US/docs/CSS/content

Here is an example:

.valid:after {
  content: '<';
  color: green;
}

.invalid:after {
  content: '>';
  color: red;
}

The problem is HTML entities are not replaced by their caracters and I still see their code.

1 Answer 1

4

CSS isn't HTML. Simply use

.valid:after {
  content: '<';
  color: green;
}

In case of need, you may also escape your characters using the unicode hexa.

For example for ▶ :

.valid:after {
  content: '\25B6';
  color: green;
}

But you don't need to escape < nor >, even if you embed your CSS in the <style> element of an HTML file.

Just in case (it might be less disturbing to your HTML editor), their codes would be \003C and \003E.

Sign up to request clarification or add additional context in comments.

1 Comment

&lt; and &gt; where just examples, in fact I want a check/cross whose entities are &#x2713; and &#x2717; then it seems to work with \2713 nor \2717 thank you !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.