David Beck's Blog

That pesky white space

Friday, September 11th, 2009

If your OCD like myself, and also suffer from the need to make websites, you may have run into this pesky problem when you lay out images and what not on a page. The problem comes when you try to mathematically determine the exact right padding so that all the objects are laid out evenly only to find that the last one falls off the end to the next line.

What’s happening? You forgot about html white space. If you put any kind of space, tab or line break between elements, it ads a space. Even worse, you may try to adjust the padding so that it looks correct in your browser, and you go to a different computer and it is a completely different distance. This is because different browsers may have different font rendering.

The solution? Remove the white space.

<img src="first.png" /><img src="second.png" />

Make sure not to put any space in between.

Filed under: Web Development Tags:

Leave a Reply