Consider the following HTML code:
<style>
td {
padding: 5px;
}
</style>
<p>
1233
</p>
<table>
<tr>
<td>
<h3>Some text</h3>
</td>
</tr>
</table>
If I use <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
, the margin
of <p>
and <h3>
does not work, but if I use <!DOCTYPE HTML>
, the margin
works.
What's more, when I add
h3 {
margin: 25px 0;
}
to the style, the margin
of them suddenly works even using HTML 4.0
doctype!
Why does this strange behavior happen? IE and Chrome behave the same on this issue, is this by design or something, it really confuse me.
I have a lot of pages written depend on this strange behavior, when I brought some CSS from other new components they defined margin then suddenly all these old pages broke. So I want to know what really happened.