How to remove “Invisible space” from HTML [duplicate]

The linebreaks are causing it – http://jsfiddle.net/RhvjF/1/

Can’t find the particular post, but smart people suggested 3 ways of fixing it:

  1. Put everything in one line (remove all line breaks)
  2. Comment out the line breaks, like

    <span style="display: inline">Hello Wo</span><!--
    --><span style="display: none;"></span><!--
    --><span style="display: inline">rld</span>
    
  3. Set the container font-size to 0 and re-set it for span-s

UPDATE

There are at least 2 more ways:

  1. Break the tags, like

    <span style="display: inline">Hello Wo</span
    ><span style="display: none;"></span
    ><span style="display: inline">rld</span>
    
  2. Float the elements, i.e. span { float: left }

Leave a Comment