The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Problems caused by omitting tags in HTML 4

HTML 4 allows authors to omit some tags. I'm preparing a presentation where I will discuss the advantages and disadvantages of omitting tags. However, I'm having trouble coming up with real-world problems caused by omitting tags.

Specifically, I'd like to show a code example where omitting a tag causes a real-world problem. Can anyone help me come up with one? Thanks.

Forgetting to close a <div id="header"> div and having a set height and overflow:hidden; on it.

Thanks for the response, but not closing a DIV will result in a validation error. I'm curious about elements that can be left unclosed within a valid document. Some examples are P, LI, DT, DD, TR, TH, TD.

Internet Explorer has problems if you do not close your P-tags. Essentially, if the P-tag isn't closed, any subsequent block-level tags that would usually implicitly close the P-tag are in fact placed inside the P.

In the following example, the TABLE will have a margin of 10px from the container, and will have a border around it:

There should be no technical problems – barring browser bugs – from omitting the tags that HTML allows to be omitted. The reason you're allowed to omit them is because they're syntactically unnecessary: their presence can be unambiguously implied.

The main drawback of omitting tags is that it can make the markup harder to read for human beings.

Internet Explorer has problems if you do not close your P-tags. Essentially, if the P-tag isn't closed, any subsequent block-level tags that would usually implicitly close the P-tag are in fact placed inside the P.

I confirmed this bug in IE6 and IE7. It did not show up in IE8 using a test document. Thanks, this is a good example.

Thanks to all others who responded as well. I now have a better understanding of this issue.