You cannot remove characters from document contents using CSS. You donβt need CSS for this. You can add symbols for visualization, generated content, but not delete.
However, you can undo character effects when rendering. Consider the following example:
<span class="number">0.15 </span>foo
Empty space ( ) has two effects: it causes a visible distance, the same as a regular space character, and prevents line breaks between "0.15" and "foo" when the browser formats the text. To prevent the last effect, you can add normal space using the generated content, but then there will be too many intervals if a line break does not appear. To fix this, set the width of the pseudo-element to zero:
.number:after { content: " "; display: inline-block; width: 0; }
To remove the interval effect without a space, you can set the negative right margin. The main problem is that the width of the space without a gap (and space) depends on the font. This is an average of about a quarter of em , but it can vary significantly. If you can consider the font as fixed (for example, you use @font-face ), you can use the following code, only with a given numeric value:
.number { display: inline-block; margin-right: -0.25em; }
As a side effect, this can also lead to line breaks between β0.15β and βfooβ, since browsers can handle inline blocks in formatting so that they always allow line breaks before and after.
source share