+7  A: 

<div/> is the XML way of closing tags, basically. <div></div> is HTML (and XML).

What DOCTYPE are you using?

From C. HTML Compatibility Guidelines in XHTML™ 1.0 The Extensible HyperText Markup Language (Second Edition):

C.3. Element Minimization and Empty Element Content

Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph) do not use the minimized form (e.g. use <p> </p> and not <p />).

cletus
Again, this is COMPATIBILITY guideline and not the actual spec. According to the spec, you can use self closing tags if you are targettinng XHTML.
SolutionYogi
Um, you'll note the OP says "HTML" page not "XHTML" page.
cletus
Yes, but if he is using the 'HTML' page, there was no point in mentioning compatibility guideline from the XHTML spec. As I linked in my answer, HTML 4 spec mandates an END tag for DIV. http://www.w3.org/TR/html401/struct/global.html#h-7.5.4
SolutionYogi
From HTML4 spec, 'Start tag: required, End tag: required' for DIV and SPAN elements.
SolutionYogi
Thanks for the answer! My DOCTYPE is the Visual Studio default: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="w3.org/1999/xhtml">;
Traveling Tech Guy
The doctype **does not determine** whether the page is parsed as XML or HTML by the browser; the HTTP Content-Type does. If you are transferring it as text/html (which is almost certainly the case), you **must** use an explicit close tag for elements which aren't self-closing, because browser will parse it using HTML rules, not XML ones.
Miles
+2  A: 

What's the DOCTYPE that you are using? DOCTYPE defines how the browser should interpret the HTML.

Browser uses Content-type header to decide how to parse the content being served. If content-type is text/html, it will be parsed as HTML and if content type is application/xhtml+xml, it will be parsed as XHTML. [Thanks Miles for the correction.]

HTML4 spec requires that you close the DIV tag with proper end tag. There are certain tags e.g. img, br, meta, which could be self-closing.

If you are using XHTML, you can self close the tag if it's empty otherwise closing tag is required.

Another tip: Always validate your HTML/XHTML against the DOCTYPE you have used, you can eliminate these kind of bugs.

SolutionYogi
That is not true. C.3 of the XHTML spec says not to use "minimized form" (self-closing) for tags that do not have an empty content model.
Rex M
This is incorrect. See the spec here: http://www.w3.org/TR/xhtml1/#h-4.6. The C3 section is not the SPEC, it's a guide about maintaining compatibility with HTML while using XHTML. Downvote was not warranted.
SolutionYogi
Replace the word "spec" in my comment with "official guideline" and it remains a valid criticism - it answers the question of why <div/> isn't working. The implementation guideline of the spec basically says not to follow that part of the spec, so saying "you can do x" is misleading and unhelpful.
Rex M
Again, the guideline is about what to do if you want to maintain compatibility. If you are using XHTML doctype, you can absolutely self close all the empty tags, no exceptions. Obviously, this will not work if your browser doesn't support XHTML doctype. I think the author might be using an HTML DOCTYPE and self closing an empty tag like how it works in XHTML doctype and that's the problem. It has nothing to do with the guideline.
SolutionYogi
"Obviously, this will not work if your browser doesn't support XHTML doctype." That's my point. Even browsers which supposedly support strict XHTML still sometimes stutter on self-closed tags.
Rex M
No, they don't. Try this http://jsbin.com/enena (XHTML doctype, self closing DIV tag). If you mix the two i.e. using XHTML constructs when using HTML doctype (or vice versa), that's when the problem arises. Also, what I wrote in my original answer was correct and you incorrectly downvoted it.
SolutionYogi
-1: The doctype has nothing to do with whether a page is parsed using HTML or XML rules. If you are transferring a page as `text/html`, it is HTML, plain and simple, and you can't rely on HTML parsing to provide the behavior that you expect for the XML self-closing syntax.
Miles
See: http://webkit.org/blog/68/understanding-html-xml-and-xhtml/
Miles
Miles, you are correct. I updated my post.
SolutionYogi
A: 

Good rule of thumb - if you can leave off the closing tag in HTML, you can self-close in XHTML. Examples: <img /> and <hr />. Otherwise, you need to explicitly close it.

Rex M
+1  A: 

You're writing non-standard HTML. When you do that, browsers can, and will, effectively rewrite your HTML to something that makes sense. IE8 rewrote your incorrectly self-closed tag one way, FF chose another, but the important point is that both had to guess.

The correct remedy is to follow the HTML standard which only allows you to self-close a handful of elements:

<area />
<base />
<basefont />
<col />
<br />
<hr />
<input />
<img />
<link />
<meta />
<param />
Triptych
The HTML standard doesn't let you use that syntax to do it though. <foo /> means the same as <foo>>. It is only poor support for HTML that allows XHTML to be hacked into something which text/html user agents can handle.
David Dorward
David - read the DTD I linked in this answer. Elements specified with the EMPTY attribute certainly can be expressed as above.
Triptych
No. They can be expressed as <area>, <base>, etc. For that matter, they could be expressed as <area /, <base /, etc (but browsers don't generally support that syntax. <base /> means the same as <base>> and thus <base>>. Since > is character data, and <base> can only appear in the <head> section (where character data is forbidden) this is invalid.
David Dorward
@David - although I can't find any authoritative statement to support it, it appears from some research that you are probably right. Do you have a W3C link explaining this? I've also read that including the space before the frontslash, as I have, will work on all legacy browsers.
Triptych
Grant Wagner