View Full Version : Easy to read code vs IE spacing

07-09-2007, 08:57 PM
I like to try and indent and space out my code, to make it somewhat readable later. However, IE, and to a limited extent, firefox will sometimes add spaces to the page, usually messing up tightly fitting images and the like. Is there any way to stop that, besides getting rid of all spaces and indention, making the code one big horrible block? A very basic example would be as follows:

<img src=whatever>
<img src=whatever>

<div><img src=whatever><img src=whatever></div>

I've been working around it, but it is still a pain to read. Just wondering if there is a better way.

07-09-2007, 08:59 PM
I do not see why it would add a spacing.
I indent my code and I do not see a problem, go with option one.

07-09-2007, 09:07 PM
More specifically, here was the actual code that did this to me the most recently:

<div class='leftalign'><img src='images/menu.revisions.gif'><img src='images/menu.corrections.gif'></div>

The images are 37 pixels high, so is the DIV they are in which has a 37px background. If I indent them as shown above, the DIV appears slightly taller in IE, causing the images to not line up, and the background to repeat vertically. Get rid of the spaces and it works fine, but the code is ugly to look at.

07-09-2007, 09:29 PM
You can float the images to the left but then you would need to clear your floated images or you can set the line-height to something like 0 if there is to be no text in the div.