Monday, February 16, 2009

When 'Inline' n <br> come together...

When 'Inline' n <br> come together:

Yes, I know that it's syntactically incorrect. I mean, that's why they call it 'inline'. We are not supposed to add <br> tag inside an inline element.
But consider this case. I have one span tag (which is basically inline) and the contents of span tag are dynamically generated. Suppose, for some cases, length of that dynamically generated content is more than length of one line. then that will overflow to next line. (which is actually equivalent to adding <br> in it). Right ?

This case, or you may call as exception, is handled differently in different browsers. Actually speaking, its handled similarly in Firefox, Chrome, Safari but not in Internet explorers. Lets see how -

So in these Non-IE browsers, what they do is they intelligently attach left side properties to upper line and right side properties to the last line. So if you add border to it then there will be in perfect [ and ] shape.

Check this -
But, internet explorer, on the other hand, treats them as two separate inline elements. Not only that, It applies css properties to both the elements. And that may cause problem in some cases. (like my last post)

In my opinion, making them two separate elements is unnecessary n actually wrong. I mean, I don't want to split my sentence in two parts then why are they using their 'Intelligence' to split it into two ?

No comments:

Post a Comment