How to highlight spaces in a tag? (CSS only)

I have the tag

<span class="block" style="width:12px;height:17px">&nbsp;tttt&nbsp;ttt&nbsp;ttttt</span>

I want to highlight only &nbsp;. How can I do it using only CSS?

Answers


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;">&nbsp;</span>tttt<span style="background-color:#F00;">&nbsp;</span>ttt&nbsp;ttttt</span>

Put the   within a span like

<span style="background-color:#F00;">&nbsp;</span>

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">&#160;</span> <span class="smallcaps" style="font-variant:small-caps;">no-break space</span>

Need Your Help

Gradle clean<customTask> not working

gradle

I have a custom task to do a Websphere EJBDeploy. I have defined the inputs and ouputs, and get successful incremental compilation, but I can't get the automatically generated clean task to work

TCP Messaging with QtNetwork in python using PyQt

python sockets chat pyqt4 messaging

I am trying to implement a TCP messaging system in my application.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.