cc.
cc.

Reputation: 5633

What I'm doing wrong in display this table?

Probably this is a stupid thing, 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>

The "Smiths" are not displayed under the "Name" cell.

Upvotes: 2

Views: 188

Answers (7)

AbstractProblemFactory
AbstractProblemFactory

Reputation: 9811

Here are great and fresh post about table explain everything http://woork.blogspot.com/2009/09/rediscovering-html-tables.html must see :)

Upvotes: 2

Alexey Busygin
Alexey Busygin

Reputation: 351

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

Replace with:

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

Upvotes: 3

Traveling Tech Guy
Traveling Tech Guy

Reputation: 27811

Fix your THead element:

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

Upvotes: 1

Omar
Omar

Reputation: 40162

Do this:

<thead>

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

</thead>

TH is just like any column () but with different default properties (bold text, center aligned text). So it has to be nested within a row ( )

Upvotes: 1

Steven Robbins
Steven Robbins

Reputation: 26599

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

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

Upvotes: 1

yoda
yoda

Reputation: 10981

th tags are "table headers", you need to place them inside tr's, "table rows".

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

or

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

Upvotes: 6

canadiancreed
canadiancreed

Reputation: 1984

Th's are the root of your problem. Placing them like so will give you one column like your'e expecting.

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

Upvotes: 1

Related Questions