Ignore whitespace in HTML [duplicate]

Oh, you can really easy accomplish that with a single line of CSS:

#parent_of_imgs { white-space-collapse: discard; }

Disadvantage, you ask? No browser has implemented this extremely useful feature (think of inline blocks in general) yet. 🙁

What I did from time to time, although it’s ugly as the night is dark, is to use comments:

<p><!--
  --><img src="https://stackoverflow.com/questions/2628050/." alt="" /><!--
  --><img src="https://stackoverflow.com/questions/2628050/." alt="" /><!--
  --><img src="https://stackoverflow.com/questions/2628050/." alt="" /><!--
  --><img src="https://stackoverflow.com/questions/2628050/." alt="" /><!--
--></p>

Leave a Comment