EN
CSS - how to add HTML non break space using content style property?
1
answers
0
points
How can I add HTML entities using CSS content property?
I wanted to add non-breaking space using but instead it prints ' ' between the words.
My code:
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<head>
<style>
span:before {
content: ' ';
}
</style>
</head>
<body>
Hello<span>World!</span>
</body>
</html>
1 answer
0
points
If you want to add HTML entities using content property, you have to use the escaped unicode of the entity.
In your case instead of ' ' use '\0000a0'.
Practical example
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<head>
<style>
span:before {
content: '\0000a0';
}
</style>
</head>
<body>
Hello<span>World!</span>
</body>
</html>
0 comments
Add comment