[英]Whitespace/Margin between <table> and <h1> of a <form> element
There is a huge amount of whitespace between <table>
and <h1>
both of which are in a form element. <table>
和<h1>
之间有大量的空格,这两个空格都在表单元素中。 As soon as I remove the <table>
element, this whitespace goes. 一旦删除<table>
元素,该空格就会消失。 I am using <table>
element to align elements to a form. 我正在使用<table>
元素将元素与表单对齐。 Can someone explain why this is happening? 有人可以解释为什么会这样吗?
<form> <h2>Form Heading goes here</h2> <table> <tr> <td>First Name</td> <td><input type="text" name="f_name"></td> </tr> <tr> <td>Last Name</td> <td><input type="text" name="l_name"></td> </tr> </table> </form>
By default, the h2 tag adds margin under it. 默认情况下,h2标签在其下方添加边距。 The following CSS will remove that space. 以下CSS将删除该空间。
CSS 的CSS
h2 {
margin-bottom: 0;
}
you have to remove the default margin of <h2>
tag. 您必须删除<h2>
标签的默认边距。
h2{ margin: 0; }
<form> <h2>Form Heading goes here</h2> <table> <tr> <td>First Name</td> <td><input type="text" name="f_name"></td> </tr> <tr> <td>Last Name</td> <td><input type="text" name="l_name"></td> </tr> </table> </form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.