Default margins of elements inside table cells

Giganews Newsgroups
Subject: Default margins of elements inside table cells
Posted by:  Jukka K. Korpela (jkorpe…@cs.tut.fi)
Date: Thu, 22 Apr 2004

I just noticed that most browsers render

<table border="1"><tr><td><p>foo</p></td></tr></table>

the same way as

<table border="1"><tr><td>foo</td></tr></table>

That is, they ignore the p markup in the sense that they don't apply the
normal default top and bottom margins. This is rather odd, especially
since they do leave some space between paragraphs, so they apparently
ignore just the top margin of the first paragraph and the bottom margin
of the last paragraph.

Mozilla and Opera seem to do the same with <blockquote>, <form>, and
<ul>, whereas IE applies a _bottom_ margin to them when they appear as
the sole content of a cell.

This is rather odd, and I don't know what to think about it. In any case,
whenever you put block elements inside a cell, you should probably
consider setting some CSS rules to suggest a particular rendering as
regards to top and bottom margin. And, in fact, you might affect them
without wanting to do so, since e.g.
p { margin: 1em 0; }
in an author style sheet affects p elements inside table cells, too, even
though it might have been meant to just fine tune the normal default
margins.

--
Yucca,http://www.cs.tut.fi/~jkorpela/

Replies