How to make HTML layout whitespace-agnostic?

Posted by ssg on Stack Overflow See other posts from Stack Overflow or by ssg
Published on 2010-04-07T21:24:08Z Indexed on 2010/04/07 21:33 UTC
Read the original article Hit count: 262

Filed under:
|

If you have consecutive inline-blocks white-space becomes significant. It adds some level of space between elements. What's the "correct" way of avoiding whitespace effect to HTML layout if you want those blocks to look stuck to each other?

Example:

<span>a</span>
<span>b</span>

This renders differently than:

<span>a</span><span>b</span>

because of the space inbetween. I want whitespace-effect to go away without compromising HTML source code layout. I want my HTML templates to stay clean and well-indented.

I think these options are ugly:

1) Tweaking text-indent, margin, padding etc. (Because it would be dependent on font-size, default white-space width etc)

2) Putting everything on a single line, next to each other.

3) Zero font-size. That would require overriding font-size in blocks, which would otherwise be inherited.

4) Possible document-wide solutions. I want the solution to stay local for a certain block of HTML.

Any ideas, any obvious points which I'm missing?

© Stack Overflow or respective owner

Related posts about css

Related posts about html