What am I doing wrong in displaying this table?

This is probably stupid, but I don't see it. What is the problem?

<html>
<body>
<form action="search" method="get">
    <input>
    <input name="action" value="search" type="submit">
</form>

<table border="1">
    <thead>
    <th>
        <td>Name</td>

    </th>
    </thead>
    <tbody>

    <tr>
        <td>Smith        </td>

    </tr>

    <tr>
        <td>Smith2        </td>
        </tr>

    </tbody>
</table>
</body>
</html>

      

Smiths do not appear under the Name cell.

+2


source to share


7 replies


th tags are "table headers", you need to put them inside tr, "table rows".

<tr>
    <th>Name</th>
</tr>

      



or

<tr>
    <td>Name</td>
</tr>

      

+6


source


<th>
  <td>Name</td>
</th>

      

Replaced by:



<tr>
  <th>Name</th>
</tr>

      

+3


source


Here is a great and fresh post about table explaining everything http://woork.blogspot.com/2009/09/rediscovering-html-tables.html should see :)

+2


source


Th is the root of your problem. Putting them in will also give you one column, as you expect.

<tr>
    <th>Name</th>
</tr>

      

+1


source


You don't need <td> </td> inside <th> and wrap it in <tr>, you need:

<tr>
    <th>
        Name
    </th>
</tr>

      

+1


source


Do it:

<thead>

<tr>
<th>
 Name
</th>
</tr>

</thead>

      

TH is just like any column (), but with different defaults (bold text, center aligned text). Therefore it must be nested in string ()

+1


source


Correct the THead element:

<thead>
  <tr>
    <th>Name</th>
  </tr>
</thead>

      

+1


source







All Articles