css 为什么我会收到这么多br标签

7vhp5slm  于 2022-12-01  发布在  其他
关注(0)|答案(4)|浏览(172)

我开始写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>
dw1jzc5e

dw1jzc5e1#

我不认为这是<br>。使用Inspect Element检查是什么导致表前有这么大的间隙。表前可能有某种margin

9udxz4iz

9udxz4iz2#

你的代码里有很多不必要的“br”标签,在你的表里。把它们都去掉,一切都会好的!干杯。

cyej8jka

cyej8jka3#

使用此代码,这可能会解决您的问题

<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>

刚移除了一些不必要的标签,这些标签可能会导致问题。请尝试

zy1mlcev

zy1mlcev4#

您的页面中有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>

相关问题