如何删除元素之间的空白行?

时间:2015-12-14 00:27:26

标签: php html css

如何删除标题和表格之间的空白行?谢谢!

  <?php
      echo "<h3>Presentaciones</h3>";
      echo "<table border='1'>";
      echo "<tr>";
      echo "<td>row 1, field1</td>";
      echo "<td>row 1, field2</td>";
      echo "<td>row 1, field3</td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td>row 2, field1</td>";
      echo "<td>row 2, field2</td>";
      echo "<td>row 2, field3</td>";
      echo "</tr>";
      echo "</table>";
  ?>

2 个答案:

答案 0 :(得分:0)

将其添加到您的css文件中:

h3 {
  margin-bottom: 0px;
}
<h3>Presentaciones</h3>
<table border='1'>
<tr>
    <td>row 1, field1</td>
    <td>row 1, field2</td>
    <td>row 1, field3</td>
</tr>
<tr>
    <td>row 2, field1</td>
    <td>row 2, field2</td>
    <td>row 2, field3</td>
</table>

答案 1 :(得分:0)

margin-bottom: 0中添加h3。 浏览器具有默认样式,您必须添加自己的规则才能覆盖它们。

以下是PHP输出为HTML:

&#13;
&#13;
h3{
margin-bottom: 0;
}
&#13;
<h3>Presentaciones</h3><table border="1"><tbody><tr><td>row 1, field1</td><td>row 1, field2</td><td>row 1, field3</td></tr><tr><td>row 2, field1</td><td>row 2, field2</td><td>row 2, field3</td></tr></tbody></table>
&#13;
&#13;
&#13;