Page 1 of 3 123 LastLast
Results 1 to 10 of 21
Like Tree2Likes

Thread: Do You Still Close HTML Tags?

  1. #1
    Andy101's Avatar
    Andy101 is offline Code Otaku
    Join Date
    Aug 2009
    Location
    Kanazawa
    Posts
    1,314
    Thanks
    178
    Thanked 309 Times in 236 Posts

    Do You Still Close HTML Tags?

    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? />
    Otaku CMS - Import a WordPress blog and manage your site using single-page App technology
    Angular Skills - new site about Front-end App. programming

  2. #2
    TopDogger's Avatar
    TopDogger is online now Über Hund
    Join Date
    Jan 2009
    Location
    Hellfire, AZ
    Posts
    3,107
    Thanks
    350
    Thanked 919 Times in 703 Posts
    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>
    "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- Benjamin Franklin


  3. #3
    Andy101's Avatar
    Andy101 is offline Code Otaku
    Join Date
    Aug 2009
    Location
    Kanazawa
    Posts
    1,314
    Thanks
    178
    Thanked 309 Times in 236 Posts
    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.

  4. #4
    TopDogger's Avatar
    TopDogger is online now Über Hund
    Join Date
    Jan 2009
    Location
    Hellfire, AZ
    Posts
    3,107
    Thanks
    350
    Thanked 919 Times in 703 Posts
    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
    Mike Dammann likes this.
    "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- Benjamin Franklin


  5. #5
    anurocked is offline Newbie Net Builder
    Join Date
    Sep 2012
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  6. #6
    Andy101's Avatar
    Andy101 is offline Code Otaku
    Join Date
    Aug 2009
    Location
    Kanazawa
    Posts
    1,314
    Thanks
    178
    Thanked 309 Times in 236 Posts
    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
    Ha ha, the time saved is in hand coding the HTML.

    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):

    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>
    It's a good example of where leaving out some closing tags cleans up the code.
    Otaku CMS - Import a WordPress blog and manage your site using single-page App technology
    Angular Skills - new site about Front-end App. programming

  7. #7
    Mike Dammann's Avatar
    Mike Dammann is offline Super Moderator
    Join Date
    Dec 2008
    Location
    Geographically flexible
    Posts
    964
    Blog Entries
    3
    Thanks
    237
    Thanked 182 Times in 148 Posts
    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.
    Quote Originally Posted by Andy101 View Post
    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? />


    ---------- Post added at 11:20 AM ---------- Previous post was at 11:19 AM ----------

    Sorry, I meant to quote this in my previous post.
    Quote Originally Posted by TopDogger View Post
    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
    For blood type dating go here. If your blood type is rhesus negative, go there. If you are bored and feel like liking a Facebook page, hit this one.

  8. #8
    Andy101's Avatar
    Andy101 is offline Code Otaku
    Join Date
    Aug 2009
    Location
    Kanazawa
    Posts
    1,314
    Thanks
    178
    Thanked 309 Times in 236 Posts
    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.
    Mike Dammann likes this.

  9. #9
    Mike Dammann's Avatar
    Mike Dammann is offline Super Moderator
    Join Date
    Dec 2008
    Location
    Geographically flexible
    Posts
    964
    Blog Entries
    3
    Thanks
    237
    Thanked 182 Times in 148 Posts
    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.




    Quote Originally Posted by Andy101 View 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.
    For blood type dating go here. If your blood type is rhesus negative, go there. If you are bored and feel like liking a Facebook page, hit this one.

  10. #10
    Andy101's Avatar
    Andy101 is offline Code Otaku
    Join Date
    Aug 2009
    Location
    Kanazawa
    Posts
    1,314
    Thanks
    178
    Thanked 309 Times in 236 Posts
    content is unique, as niche as possible with as much content as possible
    I agree with this.

    But I am not in agreement with this statement:
    low amounts of backlinks and next to no code
    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.

Page 1 of 3 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •