When is it appropriate to use a closing tag and when a slash is enough?
<div></div>
vs.
<div />
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can only use a self closing tag
<div />if your DOCTYPE is set to XHTML as this is borrowed from XML where you can have self closing tags. You can’t have it if your DOCTYPE is set to HTML 4.01 or HTML 5.http://www.w3.org/TR/xhtml1/
I’m not sure your exact use case for wanting this, but if it’s for clearing floats, you can do this instead and not have to worry about compatibility issues, especially with IE if it kicks into emulation mode.