Reputation: 4979
I have the tag
<span class="block" style="width:12px;height:17px"> tttt ttt ttttt</span>
I want to highlight only
. How can I do it using only CSS?
Upvotes: 1
Views: 2737
Reputation: 260
Well there is no such way to select the space, but if for some reason you really want to do it then, you can try something like this:
<span class="block" style="width:12px;height:17px"><span style="background-color:#F00;"> </span>tttt<span style="background-color:#F00;"> </span>ttt ttttt</span>
Put the
within a span like
<span style="background-color:#F00;"> </span>
Upvotes: 3
Reputation: 723598
You can't do this with only CSS; you will need to wrap each non-breaking space in a span
and give that span
a background color. Wikipedia does this in their article for example:
In Unicode, it is encoded as <span class="nowrap">U+00A0</span> <span class="unicode" style="background:lightblue"> </span> <span class="smallcaps" style="font-variant:small-caps;">no-break space</span>
Upvotes: 2