FAQ: Learn HTML - Tables - Table Headings

This community-built FAQ covers the “Table Headings” exercise in Codecademy’s lessons on HTML.

Here are the most popular community questions on this exercise:

Join the Discussion. We Want to Hear From You!

Have a new question or can answer someone else’s? Reply (reply) to an existing thread!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources about HTML in general? Go here!

Want to take the conversation in a totally different direction? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account, billing, Pro, or Pro Intensive? Reach out to our support team!

None of the above? Find out where to ask other questions here!

Other FAQs

The following are links to additional questions that our community has asked about this exercise:

  • This list will contain other frequently asked questions that aren’t quite as popular as the ones above.
  • Currently there have not been enough questions asked and answered about this exercise to populate this FAQ section.
  • This FAQ is built and maintained by you, the Codecademy community – help yourself and other learners like you by contributing!

Not seeing your question? It may still have been asked before – try searching for it by clicking the spyglass icon (search) in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post (reply).

2 posts were split to a new topic: Where do i put the three table headings?

Is <th> used by screen readers and does it serve any purpose other than that because the output of <tr> and <th> looks the same.

2 Likes

5 posts were split to a new topic: Should Adam’s Greenworks get a scope?

6 posts were split to a new topic: Why does the example have an empy <th>

4 posts were merged into an existing topic: This exercise discusses the scope attribute. What is the purpose of the scope attribute and are row and col the only values this attribute can have?

Table Headings

On this page, there is a bug that makes me not be able to go forward.
I click on the screen several times. It doesn’t respond at all.
Also I can’t type anything anywhere on that page.
Please let me know what I am wrong or where you have a bug.

1 Like

So, in terms of <th> vs <td> is there any reason that you couldnt use <td> to create the heading of the table, and just put it in the first row instead of using <th>? Or is this one of those things where it would technically be correct but is not the best practice?

3 Likes

i haven t noticed any diffrence betwen “td” and “th”
so what s the diffrence

3 Likes

These are what we took to be semantic elements in the day. There is a big difference, albeit they have identical behaviors, for the most part. TD is a data cell. It means, ‘table data’.

We could construct our table only of them, giving the top row cells headings instead of data values. It would be valid as far as HTML is concerned. But it would also lack the semantics that tell the reader, “this row consists of the column headings for the data below”. Furthermore, we would not give data cells a scope attribute, even if they did appear at the top. It would not make sense.

Pretty much explains the difference, right there. TH is not a data cell, but a heading or descriptor cell that applies to, as in scope="col" all the data immediately below it (the column). We can also use TH at the start of each row with given, scope="row". It would tell the user agent that this cell is not data, but a descriptor for a row of TDs in the table.

Bottom line, headings with scope belong in TH cells; data belongs in TD cells.

5 Likes

Do I need to open a <tr> element for every row I add? What if I want to make a table with 10 or more rows, do I really need to open that many <tr> elements?

Yes, since that is the ROW container. TDs are inline-blocks and cannot define multiple rows.

2 Likes

It’s a lot simpler and more straightforward to work with, compared to what we had to deal with before HTML5. Back in 2008 coding tables was like herding cats… with ONE feller that was extra sparkly.

Now this stuff’s actually making sense. Thanks for helping us stay focused, it’s good to be back in the saddle again.

1 Like

I was stuck on the following:

Table Headings, 5/13

Question 1

In the first row, add three table headings. The headings should contain the following data, in order:

  • Company Name
  • Number of Items to Ship
  • Next Action

These headings will add meaning to the rest of the data in the table.

The right answer was to dude a single quote but the instructions and HTML table advanced features and accessibility - Learn web development | MDN use double-quotes.

Could you look into it for us, please?

2 Likes

how do you create a company name

I have a question regarding the default value of scope. When it is left empty nothing changes. So how is the scope attribute is interpreted. What is the default behaviour when the scope attribute is skipped?

I just came across the same error/problem over 1 year later and it is still not fixed/addressed - it being such a small error that probably would take up almost no time to fix doesn’t bode well for my interest in buying a Membership

Why in this exercise we use scope=col instead of row.

Because we want the focus of the heading to be tied to the column below it.