Ignore whitespace in HTML [duplicate]

Is there anything in HTML/CSS that tells the browser to ignore whitespace completely?

So many times when you want to put, say, two images next to each other – you try desperately to keep the HTML readable, but the browser puts a space between them.

So instead of something like this:

<img src="https://stackoverflow.com/questions/2628050/images/minithing.jpg" alt="my mini thing" />
<img src="https://stackoverflow.com/questions/2628050/images/minithing.jpg" alt="my mini thing" />
<img src="https://stackoverflow.com/questions/2628050/images/minithing.jpg" alt="my mini thing" />
<img src="https://stackoverflow.com/questions/2628050/images/minithing.jpg" alt="my mini thing" />

you end up with this

<img src="https://stackoverflow.com/questions/2628050/images/minithing.jpg" alt="my mini thing" /><img src="https://stackoverflow.com/questions/2628050/images/minithing.jpg" alt="my mini thing" /><img src="https://stackoverflow.com/questions/2628050/images/minithing.jpg" alt="my mini thing" /><img src="https://stackoverflow.com/questions/2628050/images/minithing.jpg" alt="my mini thing" />

Which is just so horrible!

12 Answers
12

Leave a Comment