With HTML5 there seems to be no need to close tags.
I still feel compelled to close my tags but I am tempted to neglect to do so for admin area code such as for closing the body and html tags.
What are your thoughts on this? />
Printable View
With HTML5 there seems to be no need to close tags.
I still feel compelled to close my tags but I am tempted to neglect to do so for admin area code such as for closing the body and html tags.
What are your thoughts on this? />
Closing some tags is optional in HTML 5. Others are still required. I migrate a lot of sites from XHTML to HTML 5, so I leave the closing tags in place. As long as it validates with the W3C Validator, it's good to go.
You still do need to close formatting elements, such as div, span, table, tr, td, etc.
From my personal view, I always thought that coding was sloppy when closing tags were left out.
If you run this code through the W3C Validator, you will see where HTML 5 requires closing tags. I purposely omitted most of the closing tags with this test.
Code:<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="UTF-8">
<title>Netbuilders Test</title>
<body>
<div class="test">
<p>
<span>this is a test
<table>
<tr>
<td>
this is another test
</table>
Thanks TD, I tried your test. What is evident is that some tags obviously need to be closed such as span and div to make the page render as you intended. But to save bandwidth, it makes sense to stop once all the useful data has been transferred to the client.
Back in the 1990s when everyone was still on dial-up connections, we used to eliminate the quotes around attribute values in order to save bandwidth and speed up sites.
Today, I'm not sure how much you will gain by saving the 16 bytes in the closing body and html tags and carriage returns :D
I had worked in HTML in Late 90's. at that time the speed are very low today i think we don't have time ti calculate.
Ha ha, the time saved is in hand coding the HTML.Quote:
Today, I'm not sure how much you will gain by saving the 16 bytes in the closing body and html tags and carriage returns
Anyway, I realized the obvious answer to my conundrum was to read the HTML5 specification rather than using trial and error testing. There is a version for web developers at: HTML5: Edition for Web Authors
Here is an example of a Sudoku board coded using a table in HTML5 (taken from the linked document):
It's a good example of where leaving out some closing tags cleans up the code.Code:<!DOCTYPE html>
<html>
<head>
<title>Sample page</title>
</head>
<body>
<section>
<style scoped>
table { border-collapse: collapse; border: solid thick; }
colgroup, tbody { border: solid medium; }
td { border: solid thin; height: 1.4em; width: 1.4em; text-align: center; padding: 0; }
</style>
<h1>Today's Sudoku</h1>
<table>
<colgroup><col><col><col>
<colgroup><col><col><col>
<colgroup><col><col><col>
<tbody>
<tr> <td> 1 <td> <td> 3 <td> 6 <td> <td> 4 <td> 7 <td> <td> 9
<tr> <td> <td> 2 <td> <td> <td> 9 <td> <td> <td> 1 <td>
<tr> <td> 7 <td> <td> <td> <td> <td> <td> <td> <td> 6
<tbody>
<tr> <td> 2 <td> <td> 4 <td> <td> 3 <td> <td> 9 <td> <td> 8
<tr> <td> <td> <td> <td> <td> <td> <td> <td> <td>
<tr> <td> 5 <td> <td> <td> 9 <td> <td> 7 <td> <td> <td> 1
<tbody>
<tr> <td> 6 <td> <td> <td> <td> 5 <td> <td> <td> <td> 2
<tr> <td> <td> <td> <td> <td> 7 <td> <td> <td> <td>
<tr> <td> 9 <td> <td> <td> 8 <td> <td> 2 <td> <td> <td> 5
</table>
</section>
</body>
</html>
Back in those days I was taught the less code, the more Google likes your site. Looking back at some of my white background, text only pages ranking quite well, it might as well have been true, if it isn't still.
---------- Post added at 11:20 AM ---------- Previous post was at 11:19 AM ----------
Sorry, I meant to quote this in my previous post.
Some of this old-timer knowledge could be applied to mobile versions of web pages maybe? I read that the average mobile web page is 1MB in size. Of course, that is going to be rich media content rather than text.
Of course, I would need insider knowledge on the programming of the spiders to know exactly what works definitely, but my motto is to make it easiest for them to hit the content right away. Anything that could block them should be removed, even if it's a simple tag.
I still see those long one pagers here and there ranking for loads of little keyterms which adds up with enough content there.
So as far as I can tell, you can still make an impact with a new site, low amounts of backlinks and next to no code as long as the content is unique, as niche as possible with as much content as possible.
I agree with this.Quote:
content is unique, as niche as possible with as much content as possible
But I am not in agreement with this statement:
For example: Google inserts a massive amount of Javascript code into web pages that use webmaster tools. Hit F12 in Chrome to inspect the code. And newly popular sites could get a big influx of backlinks.Quote:
low amounts of backlinks and next to no code