Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML HTML Tables HTML Tables

Carson Clark
Carson Clark
2,159 Points

Why won't this work?

Could somebody possibly tell me why this won't work. What exactly is a "cell"? Isn't it the same as a row? I'm missing something! Thanks.

http://i.gyazo.com/4c9ed16ce550956ebc9b2b01ce17369f.png

4 Answers

<table>
  <thead>
    <tr>
      <th>Header 1</th>
      <th>Header 2</th>
    </tr>
  <thead>
  <tr>
    <td>Data 1</td>
    <td>Data 2</td>
  </tr>
</table>
Carson Clark
Carson Clark
2,159 Points

That doesn't really answer my question.

a table cell is <td>

Catalin Sucigan
Catalin Sucigan
15,563 Points

More specific, a table is divided into rows with the <tr> tag (as you know). A row is divided into data CELLS with the <td> tag. Too late anywayz :D

Hi Carson,

Table cells are either <td> data cell or <th> header cell

Your content is going to be inside those elements.

Tables have very specific rules about what elements can go where and in what order.

td's and th's must be contained within tr's. So a <tr> element can contain zero or more th's or td's

In your screenshot you have two problems. Your <thead> can't contain <th> children. The <th>'s must be contained within a <tr>

Also, you have placed text directly inside the table row's in your tbody section. The table rows need to contain table cells and then those cells can contain your text.

The spec isn't the easiest thing to read but this link contains the full rules for how these elements have to be used.
http://www.w3.org/TR/html5/tabular-data.html

Near the beginning of each subsection you will see Contexts in which this element can be used: and Content model: These two parts tell you where to put the elements and also what can be inside them.