I have placed a p tag in a td, like so:
<html>
<head>
<title></title>
</head>
<body>
<table>
<tr>
<td style="font-size: 16px;"><p>Hello</p></td>
</tr>
</table>
</body>
</html>
The default margins have disappeared from the p tag. Why is this the case and how can I get back the default p tag margins?
I thought it was something to do with the font-size not cascading as the p tags margins are em based, but that didn’t help.
I don’t want to directly add margins to the p tag, is there any other way?
Just add a doctype declaration to your page:
Without it, your page is displayed in quirks mode, where margins may behave unexpectedly, especially when it comes to tables. I’m not sure what exactly is happening here that causes your
pto lose its margins when in yourtd, but I do know that it only occurs in quirks mode.