Search code examples
htmlcsspseudo-elementletter-spacing

Pseudo elements: space between characters


I have a badge that adds brackets via CSS. Unfortunatelly it also adds spaces, is there a way to remove the spaces without a negative margin?
Current Output: Items ( 10 )
Desired Output: Items (10)

.badge:before {
  content: '(';
}

.badge:after {
  content: ')';
}

JSFiddle


Solution

  • It adds spaces because you've got spaces in your markup. There are no spaces if you do this:

    Items
    <span class="badge">10</span>
    <hr>
    Items (10)