Why does the example have an empy `<th>`?


Could someone please take a look at this? I’ve been stressing out over the table headings lesson for over an hour to no avail. Could someone let me know what im doing wrong? https://www.codecademy.com/courses/learn-html/lessons/tables/exercises/table-headings this is the lesson.

I’ve also seen something about a tag but it mentions nothing about this in the lesson.

The empty TH element could be the problem.

I only did that because the lesson on the left had put it too.
However I’ve tried it without and still doesn’t work.

At some point the instructions might have asked for a THEAD?

Eg.

  <table>
    <thead>
      <tr>
        <th>Company Name</th>
        <th>Number of Items to Ship</th>
        <th>Next Action</th>
      </tr>
    </thead>

Ive gone back through the instructions twice and it at no point mentioned a thead, however the solution you just gave me worked so i’ll make a note of it and carry on with the lessons. Thankyou very much sir.

1 Like

I’m answering for posterity to help other learners. The example uses an empty <th> to create a blank space in the upper left corner. This will create a table like below.

image

6 Likes

Just to add: I think the example mentions the empty TH for this reason:

The blank heading creates the extra table cell necessary to align the table headings correctly over the data they correspond to.

Which stumbled me up as well. Remove that empty TH and the lesson completes.
Perhaps the lesson/example needs updating.

The lesson may complete but the outcome will be a malformed table.

For all the beginners out there, I would like to tell you that you must add border=1 inside the

element in order to add a border to your table because if not you will not have a border for your table. Inside Codecademy it is added without border=1 outside it will not be added. Try and tell me.