Reputation: 1892
I have a website called DaltonEmpire.
When a user copies "DaltonEmpire" I would like "Dalton Empire" to be added to their clipboard.
I only came to one solution; use a space, but make the letter-spacing
-18px
.
Isn't there a neater solution, such as a HTML character for this?
My example JSFiddle and code:
span.nospace {
letter-spacing: -18px;
}
<ol>
<li>Dalton<b>Empire</b></li>
<li>Dalton‌<b>Empire</b></li>
<li>Dalton‍<b>Empire</b></li>
<li>Dalton​<b>Empire</b></li>
<li>Dalton<span class="nospace"> </span><b>Empire</b> <i>The only one that works</i>
</li>
</ol>
Upvotes: 16
Views: 55659
Reputation: 3188
Here is some interesting and related info. It doesn't solve your problem, but it may help people who are searching for a way to create an optional line-break, like I was. The Zero-Width Space ​
and <wbr>
element are two possible options.
Upvotes: 22
Reputation: 8091
You can use word-spacing
for this. However to make a more dynamic property you want to use the em
unit. This way the unit is based on the font-size, so actually supports all the font families and font sizes:
ol li
{
word-spacing: -.2em;
}
em is not an absolute unit - it is a unit that is relative to the currently chosen font size.
source: Why em instead of px?
Upvotes: 7
Reputation: 1890
you can give margin-left
or Font-size
CSS property
span.nospace {
margin-left: -4px; /* or font-size:0px */
}
Upvotes: 0
Reputation: 7133
How about this? Looks neat enough to me:
ol li{
word-spacing: -4px; /* just enter an appropriate amount here */
}
You can now remove the nospace span.
Upvotes: 1
Reputation: 85545
You can also use font-size: 0;
demo
span.nospace {
font-size: 0;
}
Upvotes: 6