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 trialKaila Orr
813 PointsHow do you add two table cells inside a table row?
I just need to understand what I am doing wrong
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML Tables</title>
</head>
<body>
<table>
<tr>
<tb>second</tb>
<tb>...</tb>
</tr>
<tr>
<td>Name</td>
<td>E-mail</td>
<td>Job Role</td>
<td>Number</td>
</tr>
<tr>
<tb>hold</tb>
<tb>on</tb>
</tr>
<tr>
<td>Nick Peter</td>
<td>Nick@example.com</td>
<td>Web Designer</td>
<td>555-555-5555</td>
</tr>
<tr>
<tb>wait</tb>
<tb>a</tb>
</tr>
<tr>
<td>Nelson Sadmen</td>
<td>Neslon@example.com</td>
<td>Front-End Developer</td>
<td>555-555-5555</td>
</tr>
<tr>
<tb>second</tb>
<tb>...</tb>
</tr>
<tr>
<td>Dave McFarland</td>
<td>Dave@example.com</td>
<td>Front-End Developer</td>
<td>555-555-5555</td>
</tr>
<tr>
<tb>second</tb>
<tb>...</tb>
</tr>
</body>
</html>
1 Answer
Eric Butler
33,512 PointsEchoing Muhammad's comment into an answer to make sure you see that this has been answered (Thanks, Muhammad!):
- There's no such thing as a
<tb>
element. Table cells can only use the<td>
(Table Data) or<th>
(Table Header) tag. You'll almost always use<td>
. - If you don't have a consistent number of table cells in each row, your table will be off-balance. If a table cell is supposed to span 2 columns, you'd set it as
<td colspan="2">whatever</td>
. Same thing with any other number of columns it should span. Extra note: there's no such thing as, for example,colspan="all"
, you have to count the columns and use a number. - You never close your table. Use
</table>
between your last</tr>
tag and the</body>
tag.
Muhammad Tahir
4,113 PointsMuhammad Tahir
4,113 PointsYou are using <tb>, replace those with <td>. Also you should be using same number of cells for a single table's row or use colspan to span the cell into multiple columns. You can also nest tables within a single cell for the purpose.