Welcome to WebmasterWorld Guest from 54.145.173.147

Forum Moderators: not2easy

Message Too Old, No Replies

CSS question

spacing between images

   
1:06 am on Aug 25, 2001 (gmt 0)

10+ Year Member



I'm trying to layout a navigation bar thats going to have 6 or 7 images side by side. I figured it would be easier to position them by adding a class to define their vertical position, but just letting the document flow determine the horizontal position, rather than positioning each one separately. When placing two images side by side (by using the <img> element twice in a row) there's a space of a few pixels between the images. Is there a way in CSS to remove this space? Or is it best to just make an ID for each part of the nav bar and position them each separately. Or maybe I should just use an image map............. Any suggestions?
2:39 am on Aug 25, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Jake,
You don't need CSS to remove the spaces. Put all of your <img> tags ON THE SAME LINE, without a space or newline.

Like this:

<img src="x.jpg"><img src="y.jgp"><img src="z.jpg">

This will work, money back guarantee.

Buy the way, welcome to the forum!

2:51 am on Aug 25, 2001 (gmt 0)

10+ Year Member



aha! Guess I need to brush up on my html! thanks.....

gph

2:39 am on Apr 30, 2002 (gmt 0)

10+ Year Member



Could someone explain why it is necessary to have everything on the same line?
5:18 am on Apr 30, 2002 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The main issue is cross-browser display. Even though line breaks and extra spaces in HTML code are "supposed to be" ignored by browsers, in practice that's not the way it always works out.

Newer browser versions are pretty good on this, but Netscape 4, for instance, and some earlier IE5 versions had nasty little display quirks that would crop up around line breaks and spaces.

gph

5:34 am on Apr 30, 2002 (gmt 0)

10+ Year Member



Thanks for the info Tedster. I've run across this a couple of times and had no idea why it was happening.
5:55 am on Apr 30, 2002 (gmt 0)

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Strictly speaking, this is not a browser error. Generally you want a line break in source to be interpreted as a space, but the case of images and links are an exception.

Anyway, CSS gives you some noteworthy advantages over tables for displaying images and captions. Check out the following:

[glish.com ]

[bluerobot.com ]
[thenoodleincident.com ]

Cheers,

Tom