The HTML code below consistently results in TEXT A and TEXTB not being horizontally aligned but removing <div style="display:none;"> </div> fixes the alignment. I discovered that using div elements instead of p elements fixing this issue, but am wondering what is actually going on. I saw this behavior in in Opera, Firefox, IE (IE actually puts TEXTB on a separate line), and Chrome.
My expectation was that a div with display:none would not have any impact on formatting.
<html>
<body>
<div style="border-top-style: solid;">
<p style="float:left; width:280px;">
TEXT A<div style="display:none;"> </div>
</p>
<p style="float:left;">
TEXTB
</p>
</div>
</body>
</html>
divis not a valid child ofp, so the browser applies error correction to the HTML to end up with this:(HTML taken from Chrome’s Inspector)
Note the extra
pelement.