Easy to demonstrate browser bug: too much space on last <br> in a small font span

This simple code fragment exhibits a possible IE 6 bug:

<html>
<head>
</head>
<body>
    <span style="font-size:10">test<br>test<br>test</span>
</body>
</html>

Basically it acts as if the final <br> between the last 2 words "test" were actually two breaks (i.e. <br><br>).
The problem goes away with larger fonts. For font-size:20 there is no problem!!
What is going on here? Anybody know a work around?

roricka
rorickaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DaveSWCommented:
Put units after the font-size:10

e.g.

font-size:100%;
font-size:1em;

etc

And that seems to fix it.
0
dorwardCommented:
and of course, when the CSS is invalid (which when its lacking a unit it is), then its can't be a browser bug - well, it is - it should ignore the font size entirely.
0
rorickaAuthor Commented:
Thanks DaveSW, but did you try it?? Because neither using 70% nor .7em  helps me. Both of these show the error (remember -- it only shows up with a smallish font.)

Did you actually TRY your suggestion? I mean, first make sure you are seeing the problem, THEN make the change you suggest. Are you REALLY seeing the problem, and then seeing it go away??

roricka
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

rorickaAuthor Commented:
Incidentally, a work around I found myself, but which can't always be used, is to just put ANOTHER <br> at the end. THEN THAT one is the one, apparently, that gets doubled (or whatever) and the previous <br> appears correctly. But what the heck is going on? Why does only the FINAL <br> fail to work properly??

roricka
0
DaveSWCommented:
well it worked for me but I didn't try it with a small font. That's probably the problem
0
HeadAcheMikeCommented:
putting the closing span tag on a new line fixed it when i tried it:

<html>
<head>
</head>
<body>
    <span style="font-size:10">test<br>test<br>test
    </span>
</body>
</html>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HeadAcheMikeCommented:
i dont know if youd call that a bug or not, more of a "its just that way" situation

i noticed awhile back i encountered a similar problem with the closing </td> tag in a table, i had an image in the cell and putting the </td> on the line below caused it to show an extra gap around the image whereas moving the tag onto the same line that featured the image tag fixed the problem and got rid of the gap.
0
seanpowellCommented:
It certainly is a bug as far as I'm concerned - because it obviously shouldn't be happening, and doesn't across all browsers

Consider:
<span style="font-size:10px; border:solid 1px #000000;">test<br>test<br>test<br>test</span>

This gives you an idea of what the browser is doing to the span elements :-(
 I wish I could say it's just IE, but it's not. NS4 (no kidding) and Mozilla get confused as well. Suprisingly, NS6 and 7 and Opera handle it just fine.

So until that happy day arrives when everyone gets it, use this:
<div style="font-size:10px;">test<br>test<br>test<br>test</div>
0
rorickaAuthor Commented:
Thanks for all the help.

I knew using <div> would solve the problem, but I specifically wanted a work-around with <span>. So putting the </span> on another line does the trick. Odd!

I've known about the </td> thing (that putting it on a new line can generate a little unwanted vertical whitespace) ever since tracking it down myself a few years ago. But how odd that here is a similar problem, but the fix is just the opposite! (I.e. making sure to put the end-tag on a new line rather than making sure to put the end-tag on the same line.)

Thanks to georgemarian for the illuminating example. Unfortunately it shines with a very dark light!

roricka
0
rorickaAuthor Commented:
I've already accepted a solution, but here is ANOTHER variant on this problem that I just discovered (at least I think it must be related.)

In trying to be sure that all font sizes are assigned through styles to prevent the user's browser font setting (i.e. with IE, the View|Text Size|Largest...Smallest etc.) from affecting the appearance of a web page, I discovered the following anomaly. Note the following code:

<html>
<head>
</head>
<body style="margin-top:0px">
    <span style="font-size:10px">test</span>
</body>
</html>

Look at the position of the word "test" with the extreme browser settings (i.e. Largest vs. Smallest, as described above.) Notice how it jumps (again, this positional difference disappears with a font, say, of 20px instead of 10px.) And note, the jump disappears when the </span> is on the next line!! Recal: before the problem was using a <br> tag. Now the problem is having the user change a browser setting. Anybody see a relationship between these two? I am perplexed! (And how come I've never noticed this stuff before? ;-) )

roricka

0
rorickaAuthor Commented:
Just discovered ANOTHER wrinkle to the above View|Text Size issue. IF, instead of placing the </span> tag on the next line, you just put a simple space at the end of the word "test" before the </span> tag on the same line, the problem goes away! AND, if instead of a space you use a &nbsp; the problem DOESN'T go away!! Whaaa??

roricka
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.