Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Email Design Designing Email with CSS Applying CSS to the Content Blocks

Elizabeth Naughton
Elizabeth Naughton
374 Points

tr vs. table

In the code, you have <tr> with the <td id="bodyCell"> Then you put a <table> within that called "emailContainer". Why do you need the "bodyCell" <tr>? Why not just the <table>?

1 Answer

Hi Elizabeth,

I think you meant "Why do you need the "bodyCell" <td>?" Also, I'm assuming you're asking why not put the <table> in the <tr> directly. I'll update my answer if this is not correct.

It has to do with how tables are structured in the html specification that the w3c has created. There is a certain structure and set of rules that browsers are supposed to follow.

The tr element is meant to be a container for td or th elements. These are the only elements that should be used inside a tr

All of your table content should always be contained within a td or th. In this case, the content happens to be another table. So that entire nested table should be contained entirely within a single td element.

this is valid html:

<table>
    <tr>
        <td>
            <table>
            </table>
        </td>
    </tr>
</table>

This is not valid:

<table>
    <tr>
        <table>
        </table>
    </tr>
</table>