Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
May 19, 2006, 5:36 pm
rate this thread
When one encounters mysterious gaps between elements, like:
it's typically because the browser renders whitespace in the code as
text. (Like a space character.) The usual solution offered is to remove
any whitespace in the code, like this:
or like this:
Ick! Is there a more elegant workaround that doesn't involve modifying
the HTML? Perhaps some CSS? Font-size has no effect whatsoever on the
gap. I couldn't find anything except the code-related solutions above.
Thanks for your help.
Re: Gaps caused by whitespace: solutions without changing HTML code?
You might put it that way. Anyway, you have real space characters between
the <img> elements, too. By the way, why do you use invalid markup, without
alt attributes? (To write sketchy code, <img> would be sufficient, so the
odds are that you really intend to omit alt attributes.)
Well, maybe. Or simply just
<div><img ...><img ...></div>
Ick indeed. Comments considered harmful (in HTML). People just shoot
themselves on the foot with them.
No. You are not supposed to be able to remove character data (including
spaces) from HTML documents without actually removing it.
You could play with positioning. But why are you trying to avoid the most
obvious and simplest solution, inventing possible workarounds that just
might work on sunny days (when CSS is on)?
It has. Try setting font-size:60px to see the difference.