Dan Dan - 6 months ago 30
CSS Question

Add whitepaces with ::before selector

I have tried this but it didn't work:



.stackoverflow::before {
font-family: 'FontAwesome';
content: "\f16c ";
}

<html>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
<a class="stack-link stackoverflow" href="http://stackoverflow.com">StackOverflow</a>
</html>





Can we add whitespace(s) with
::before
selector and
content
property like that?

Answer

Yes, You can add whitespace like this content: "\f16c \00a0";

Jsfiddle

\00a0 is hex code for a non-breaking space,used in content property. More Info

Hope it helps :)