Why new line is added in HTML?

3988 views html
-4

When I code like this:

<html>

<body>
  <table width="250">
    <tr>
      <td>
        <select>
          <option>AAA</option>
        </select>
      </td>
      <td>
        a <input type="text">
      </td>
    </tr>
  </table>
</body>

</html>

There's no newline between 'a' and textbox.

But, when I code like this:

<html>

<head>
  <style rel="stylesheet">
    select {
      width: 250px;
    }
  </style>
</head>

<body>
  <table width="250">
    <tr>
      <td>
        <select>
          <option>AAA</option>
        </select>
      </td>
      <td>
        a <input type="text">
      </td>
    </tr>
  </table>
</body>

</html>

There's new line between 'a' and textbox.

I just added 5 lines.

How can I make it with no new line?

answered question

2 Answers

7

It's because your select is the same width as the entire table. You should either make the table wider or your select narrower.

<html>

<head>
  <style rel="stylesheet">
    select {
      width: 250px;
    }
  </style>
</head>

<body>
  <table width="500">
    <tr>
      <td>
        <select>
          <option>AAA</option>
        </select>
      </td>
      <td>
        a <input type="text">
      </td>
    </tr>
  </table>
</body>

</html>

posted this
11

first of all remove two closing tag .. I don't know why your code is not working ... but if you want no new line between a and input wrap them inside

<p>

posted this

Have an answer?

JD

Please login first before posting an answer.