Stratos Asimis February 2016

CSS Text hightlight without space

Hey I was wondering if it's possible in css(or maybe javascript) when highlighting the text to affect only the words? (without the in between space)

For example as seen in this website

#somediv::selection{background: #ffb7b7;}

thus far this only change the whole text-selected color


Marty February 2016

Maybe something like:

p::selection {
  background-color: transparent;
  color: red;

div {
  color: white;
  background: blue;
  <p>Some great text.</p>

Fri Day February 2016

I dont know what exactly you are speaking of but i think it is the border.

css for a border goes like this:

margin-right: 20px;
border: 2px solid ##F89B29;">

or you can do this if you want the font color


epascarello February 2016

The CSS from their site:

::-moz-selection {
    background-color: #fff;
    color: #111;
::selection {
    background-color: #fff;
    color: #ff7264;
::-moz-selection {
    background-color: #fff;
    color: #ff7264;
<p>This is text and I love bacon</p>

The difference is setting the background color.

Fri Day February 2016

Do you mean like this:

<span style="background:blue">Bacon</span> <span style="background:blue">is</span> <span style="background:blue">Awesome</span>
I belive this is what you are looking for

Post Status

Asked in February 2016
Viewed 2,512 times
Voted 10
Answered 4 times


Leave an answer