Reputation: 33381
Consider the following Html:
<div class="one">
<span>1. test</span>
<span>test</span>
</div>
<div class="two">
<span>2. test</span><span>test</span>
</div>
The result is:
1. test test
2. testtest
I need a piece of CSS that will remove the space (or enter) between the two words of the 1st line so it will look like the 2nd line. Is it possible to remove the space with CSS?
Clarification: I'm searching for a solution without having to adjust the html!
Upvotes: 1
Views: 4195
Reputation: 801
basically you can't remove enters with css. You could do it by script or prevent them from appearing by adjusting the source.
Upvotes: 2
Reputation: 22076
If you want to remove White Spaces
between the words it is not possible using CSS because White Space
is a character. If you decrease spacing between the words it will condense whole text. Other option is to use JavaScript or Jquery.
Upvotes: 0
Reputation: 27624
.one {word-spacing: -4px;}
.one span {word-spacing: normal;}
If there are only spans in the div, remove (or neutralise) the word-spacing from the div then reset it to normal for the actual spans
As rightly pointed out by @Alohci in the comments on their answer the space between words is font-size dependant so it might be better to use -0.25em
instead of -4px
. this is a quarter of the default (4px being a quarter of 'default' 16px) note this is also font-family dependant, however it should be much more robust to use the em
s
Upvotes: 5
Reputation: 19835
No, but you can do that in your HTML code:
<div class="one">
<span>1. test</span><!--
--><span>test</span>
</div>
For example: http://jsfiddle.net/sh2Pr/
Upvotes: 0