我开始编写HTML代码,当我在chrome上查看它时,表格显示在一个很长的空白区域之后。当我检查元素时,在chrome上,我得到了很多br标签,但我没有在代码中给出任何br标签
怎么回事?
<!DOCTYPE html>
<head>
<title> Practice </title>
</head>
<body>
<table border="0.00001" align="center" bgcolor="silver">
<caption align="center"> <big><big><b> Registration Form </b><big><big> </caption><br><br>
<form name="My Form" action="" method="">
<tr>
<td> Username </td>
<td> <input type="text" name="t1" size="6"/> </td>
</tr><br><br>
<tr>
<td> Password </td>
<td> <input type="password" name="t2" size="6"/> </td>
</tr><br><br>
<tr>
<td> Name </td>
<td> <input type="text" name="t3" size="30"/> </td>
</tr><br><br>
<tr>
<td> Address </td>
<td> <input type="text" name="t4" size="30"/> </td>
</tr><br><br>
<tr>
<td> Country </td>
<td><select name="s1">
<option> Select Your Country </option>
<option> Afghanistan </option>
<option> Bangladesh </option>
<option> China </option>
<option> India </option>
<option> Russia </option>
</select></td>
</tr><br><br>
<tr>
<td> Zip Code </td>
<td> <input type="text" name="t5" size="6"/> </td>
</tr><br><br>
<tr>
<td> Email </td>
<td> <input type="text" name="t6" size="30"/> </td>
</tr><br><br>
<tr>
<td>Sex</td>
<td><input type="radio" name="r1" value="100" checked/>Male
<input type="radio" name="r1" value="102"/>Female</td>
</tr><br><br>
<tr>
<td>Language</td>
<td><input type="checkbox" name="r1" value="100" checked/>English
<input type="checkbox" name="r2" value="102"/>Non English</td>
</tr><br><br>
<tr>
<td> About </td>
<td><textarea name="a1" rows="5" cols="32"> </textarea></td>
</tr><br><br>
<tr align="centre">
<td><input type="submit" name="b2" value="submit here"/></td>
</tr><br><br>
</form>
</table>
答案 0 :(得分:0)
我认为这不是<br>
。使用Inspect Element
检查在表格之前造成这么大差距的原因。在表格之前可能存在某种margin
。
答案 1 :(得分:0)
您的代码中,表格中有很多不必要的“br”标记。将它们全部删除,一切都会好的!干杯。
答案 2 :(得分:0)
使用此代码,这可能会解决您的问题
<table border="0.00001" align="center" bgcolor="silver" cellpadding="10">
<caption align="center"><b> Registration Form </b> </caption><br><br>
<form name="My Form" action="" method="">
<tr>
<td> Username </td>
<td> <input type="text" name="t1" size="6"/> </td>
</tr>
<tr>
<td> Password </td>
<td> <input type="password" name="t2" size="6"/> </td>
</tr>
<tr>
<td> Name </td>
<td> <input type="text" name="t3" size="30"/> </td>
</tr>
<tr>
<td> Address </td>
<td> <input type="text" name="t4" size="30"/> </td>
</tr>
<tr>
<td> Country </td>
<td><select name="s1">
<option> Select Your Country </option>
<option> Afghanistan </option>
<option> Bangladesh </option>
<option> China </option>
<option> India </option>
<option> Russia </option>
</select></td>
</tr>
<tr>
<td> Zip Code </td>
<td> <input type="text" name="t5" size="6"/> </td>
</tr>
<tr>
<td> Email </td>
<td> <input type="text" name="t6" size="30"/> </td>
</tr>
<tr>
<td>Sex</td>
<td><input type="radio" name="r1" value="100" checked/>Male
<input type="radio" name="r1" value="102"/>Female</td>
</tr>
<tr>
<td>Language</td>
<td><input type="checkbox" name="r1" value="100" checked/>English
<input type="checkbox" name="r2" value="102"/>Non English</td>
</tr>
<tr>
<td> About </td>
<td><textarea name="a1" rows="5" cols="32"> </textarea></td>
</tr>
<tr align="centre">
<td><input type="submit" name="b2" value="submit here"/></td>
</tr>
</form>
</table>
刚刚删除了一些可能导致问题的不必要的标签。请尝试
答案 3 :(得分:0)
您的网页中有a lot of LF。你需要检查你的编辑器
你还有无效的标签和错过的CSS
这是一个验证
的固定版本
<!DOCTYPE html>
<html>
<head>
<title> Practice </title>
<style>
table {
border: 0.00001px;
background-color: silver;
margin: 0px auto;
}
caption {
text-align: center;
font-size: x-large;
}
.center {
text-align: center;
}
</style>
</head>
<body>
<form name="MyForm">
<table>
<caption>Registration Form</caption>
<tr>
<td>Username</td>
<td>
<input type="text" name="t1" size="6" /> </td>
</tr>
<tr>
<td>Password</td>
<td>
<input type="password" name="t2" size="6" /> </td>
</tr>
<tr>
<td>Name</td>
<td>
<input type="text" name="t3" size="30" /> </td>
</tr>
<tr>
<td>Address</td>
<td>
<input type="text" name="t4" size="30" /> </td>
</tr>
<tr>
<td>Country</td>
<td>
<select name="s1">
<option> Select Your Country </option>
<option> Afghanistan </option>
<option> Bangladesh </option>
<option> China </option>
<option> India </option>
<option> Russia </option>
</select>
</td>
</tr>
<tr>
<td>Zip Code</td>
<td>
<input type="text" name="t5" size="6" /> </td>
</tr>
<tr>
<td>Email</td>
<td>
<input type="text" name="t6" size="30" /> </td>
</tr>
<tr>
<td>Gender</td>
<td>
<input type="radio" name="r1" value="100" checked/>Male
<input type="radio" name="r1" value="102" />Female</td>
<input type="radio" name="r1" value="103" />Irrelevant</td>
</tr>
<tr>
<td>Language</td>
<td>
<input type="checkbox" name="r1" value="100" checked/>English
<input type="checkbox" name="r2" value="102" />Non English</td>
</tr>
<tr>
<td>About</td>
<td>
<textarea name="a1" rows="5" cols="32"> </textarea>
</td>
</tr>
<tr>
<td class="center" colspan="2">
<input type="submit" name="b2" value="submit here" />
</td>
</tr>
</table>
</form>
</body>
</html>