so i am starting to use more of <br /> and <div style="clear: both" / >... which is the XHTML style... now, won't those actually confuse the old browsers? for example, will the old browser treat the "div" as not closing, and so everything after the div will be treated as part of that div?
Who suggested using <div /> instead of using an opening and closing tag? Also, I think it's okay to continue this in your other topic, right? http://forums.digitalpoint.com/showthread.php?t=370584
Umm... no. If you look at the first post again, there is a code written like so: <div style="clear: both" /> Code (markup): Ignoring the style attribute, that is <div />. I was asking why that instead of a more compatible <div></div>
Well for starters, DIV has an explicit closing tag, so you should be using it to begin with. Self-closing tag styles are only meant for those elements that don't have them (such as BR, HR, IMG, INPUT, and so forth).
i see... so for elements with a closing tag, do not self close it unless you know the audience will be using XHTML browser... so for <br />, the older browsers all interpret it as <br something_unknown> and therefore <br>? (kind of like <p foobar="abc"> will be taken as <p>)
Don't self-close it period. Remember, even though your pages may be coded in XHTML, if you're using the text/html MIME type, the browser will be interpreting your page as HTML, not XHTML. I highly recommend you read these threads on SitePoint: Frequently Asked Questions about HTML XHTML vs HTML FAQ XHTML 1.0 vs XHTML 1.1
Talking of which, if you'd really like to be all XML style, then I believe the MIME type is application/xml+xhtml. Anyway, my preferred method is a <hr style="clear: both;" /> or using a <br style="clear: both;" /> since divs are meant to be used for page sections or divisions. Technically it's a case of semantics: I use hr when I feel I need to indicate a separation in the page. I also use it to keep the page useful in browsers that cannot interpret CSS. Also, you're better off just making a class called .clear with those attributes, it'll save you a bit of and keep you from using inline CSS, which isn't that great.
And <br /> is meant to be a line break, not a float clearing device. I hardly ever use line breaks except when using poetry (haikus are a popular example) or forcing label/input fields onto new lines (just two examples, others include addresses for instance). I NEVER use line breaks to clear floats. Just clear the element that follows the floated one.
Yup, or that. But when there's nothing else to follow... Legacy ones so it seems. You'll probably need to add display: block; to make it fully effective.
i wonder is the display: block to start a new line? i thought by default div will start a new line, thus moving the flow beyond the floated element. hm... maybe the most effective way can be <div style="clear: both; visibility: hidden">ha</div> just so that if some brower doesn't move the flow when there is nothing to display.