THead and TBody

Is it good to use THead and TBody?

You should use it if your table can take advantages of it. You should use them if possible.

Same with tfoot.

http://www.w3.org/TR/html401/struct/tables.html#h-11.2.3

This division enables user agents to support scrolling of table bodies independently of the table head and foot. When long tables are printed, the table head and foot information may be repeated on each page that contains table data.

Do they exist in HTML5 too? (I’m still stuck with HTML4)

You don’tneed to restrict yourself to HTML4. It’s not like a PHP version you just upgrade your server or whatever.

HTML5 only ADDS to what you can do. It’s like …HTML4 is peanut butter and bologna. That’s awesome and can make great sandwiches.

HTML5 is like roast beef, cheese, and the tears of your enemies.

Great sandwiches can be made, and more options.

1 Like

This summer I hope to buys some SitePoint books on more client facing things (e.g. HTML5, JavaScript, etc.)

Until then, my outdated knowledge will have to do!

According to w3schools…

“Differences Between HTML 4.01 and HTML5
Most of the attributes in HTML 4.01 are not supported in HTML5.”

Do not believe that at all. W3schools is stupid.

Please trust me when I say HTML5 is purely additive to your code. Not replacement.

Okay.

Exampe:
type="email’ on <input> is HTML5. What happens if the user is on a browser that doesn’t support type=“email”? It gets treated as type=“text”.

However if users are on browsers that support that HTML5 feature, phones will give updated keyboards to users, it will validate the input upon submit to make sure the usre is entering in an email (additive to whatever validation you have in place.)

W3schools is pretty oudated. It’s nice for a quick reference to what a property syntax is or something but I’d never use it as a reference tool for up to date content.

So is there an up-to-date reference for HTML5 somewhere out there?

Not really. Just google stuff and search for pages updated recently.

There were still a few pages there teaching HTML 3.2 the last time I looked.

Not as badly out of date as their JavaScript section though although I know they have been working hard to bring that section into the early 21st Century.

I would agree with Ryan that W3schools is not a reliable source, but…

[quote=“mikey_w, post:7, topic:146651”]
According to w3schools…

“Differences Between HTML 4.01 and HTML5Most of the attributes in HTML 4.01 are not supported in HTML5.”
[/quote]…in this case I believe they’re correct.

HTML attributes are not the same thing as HTML elements. Most of those attributes should not be used because they have long since been replaced by CSS.

2 Likes

Is it worth pointing out that there’s quite a difference between what the specifications for HTML4 and HTML5 say, and what the browser manufacturers build into their products? Whilst the specifications for HTML may have moved on, and older attributes depreciated, or removed from it, that doesn’t mean that browsers won’t still recognise the attributes and understand how to handle them. Most browsers offer quite a degree of backward compatibility.

2 Likes

There is a HUGE difference between “should not be used” and “not supported”. They all will still work. Which is what Mikey thought that statement meant.

The tbody is always present whether you put it in the html or not and therefore it is a good idea to always include it. Otherwise you could spend hours scratching your head as to why this won;t work.

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
table > tr > td {background:red}
</style>
</head>

<body>
<table>
		<tr>
				<td>test</td>
		</tr>
</table>
</body>
</html>

For the above to work the css would need to be:

 table > tbody > tr > td {background:red}

It catches a lot of people out.

Also note that when using thead and tfoot they both precede the tbody. The tfoot does not go after tbody.

Ah if only that were true :slight_smile: No browsers support this at the moment unless the tbody is changed to display:block but then of course it no longer behaves like a table so is useless as a method for scrolling all but one-celled tables.

All of the attributes that have been replaced by CSS were flagged as deprecated in HTML 4 which means they ought to have been completely removed in HTML 5. In fact that did not happen. All of those attributes from HTML 3.2 that were flagged for removal by HTML 4 have been downgraded to obsolete in HTML 5 (effectively adding them back into what is allowed to be used since they are no about to be removed any more).

So w3schools has it backwards in that attributes that HTML 4 deleted have effectively been added back by HTML 5.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.