Forum Moderators: open

Message Too Old, No Replies

Div doesn't need an ending tag? O_o

Atleast not in HTML 4.01 Strict...

         

Wertigon

7:12 pm on Oct 31, 2003 (gmt 0)

10+ Year Member



I was playing around with a layout and had forgotten to remove a <div> start tag. All of a sudden, it broke, on something that had worked before.

Now, I was all **** and tried to validate it. It validated perfectly. So I teared the code apart and still couldn't find the problem, until I viewed it in Opera with the debugging stylesheet turned on. That solved it.

Anyhow, I re-validated, thinking there was some </div> I was missing... But it still validated! O_o The only thing I had done was to remove an opening <div>.

So, how come the <div> can be an empty element? I thought it was defined as a block element, and that all block elements must be closed...

lorax

7:28 pm on Oct 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What were you validating for? HTML 4 strict, transistional, XHTML?

Wertigon

11:23 am on Nov 1, 2003 (gmt 0)

10+ Year Member



HTML 4.01 Strict with the W3C validator.

lorax

6:43 pm on Nov 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Well I tried the following code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>My first HTML document</TITLE>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
</HEAD>
<BODY>
<div>Testing - Hello World.</div>
</BODY>
</HTML>

which validates for HTML 4.01 Strict. When I removed either the opening or the closing tag - it wouldn't validate. So I'm not sure what's going on with your code but the validator does require both the opening and closing tag for the DIV element be present.

Wertigon

11:53 am on Nov 2, 2003 (gmt 0)

10+ Year Member



Hmmmm...

Strange, I can't seem to reproduce it either.

Might've been that W3C discovered the bug and fixed it, or that I was mistaken and there was no bug in the first place. But whatever the reason, it correctly warns now atleast.

Dammit, I wish I had saved a backup of the faulty code... Ah well. I'll make sure to do it next time. :)

Thanks for the help, appreciate it.

g1smd

12:57 pm on Nov 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I had a piece of code that validated when it should not have.

I had ....some content text/font></td></tr></table>

It broke in the browser, but not in the validator; however it only took a moment to spot what the problem really was.

The W3C validator does not always find every single error.