Couldn’t we use a `<tr>` tag rather than the `<tfoot>` tag for the footer instead?


#1

Question

Couldn’t we use a <tr> tag rather than the <tfoot> tag for the footer instead?

Answer

Yes we could use a <tr> tag and omit the <tfoot> tag altogether. While browsers might not complain, it’s important to realize that including the semantic <tfoot> tag improves the accessibility and the user experience of our page.

When our tables have footer information, it is best practice to nest that information within the semantic <tfoot> tag.


FAQ: Learn HTML Tables - Tables - Table Footer
#2

sir,with <tr>or with out using it inside the <tfoot> the results are same. it only showing the data in rows why not in column’s??


#3

We could but as I understand it we shouldn’t. As @wiki-bot has emphasised, the best-practice of nesting the info within the semantic tag where necessary.


#4

spot on @mkiscoding!

We can find good articles why semantic markup:

https://shapeshed.com/the-importance-of-semantic-markup/

is very important.

The tricky thing is when you just start learning HTML, semantic markup does not seem very important, which is why its important that experienced programmers empathize to new learners that semantic markup is very important.

Experienced programmers have the experience of building projects, from which they learned how important semantic markup is.


#5

noted that with or without <tr> inside <tfoot> , result as same .
Is it compulsory to add <tr> inside ,<tfoot > ? TQ


#6

yes, looking at the documentation:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tfoot

we can see the permitted content: Zero or more <tr> elements.

sure, browser are very error resistance, but you should still follow the right way for a variety of reasons (for other developers working on your code, helping tools for people with poor vision, SEO and more)