One consideration in the way that you code your web pages is whether or not to include optional closing tags. Of course if you are coding to the XHTML standard then there is no such thing as an optional closing tag and you have therefore already made your choice as to how you are going to code the tags in your page.
If you are using any version of HTML then some closing tags are considered to be optional and you can therefore make up your own mind as to whether to include them or not. In fact HTML allows some thags to be completely optional as to whether you include them or not. Where you don't include these tags then the browser has to decide for itself where the closing tag would be.
Leaving out closing tags makes your page source slightly shorter and therefore slightly faster loading. If you get large numbers of visitors to your page then the bandwidth saving from leaving out optional closing tags may be worth it. In extreme cases (such as the Google home page) leaving out closing tags may make a sufficient bandwidth saving to avoid the expense of purchasing additional servers in yet more data centres in order to spread the load to a managable level. The Google home page does carry leaving out things to the extreme with it even omitting the parts of the doctype that the browsers don't look at.
For most web pages the additional overhead of a few extra closing tags is not going to significantly affect the resources that the page requires and so we have the option of including those tags. Why would we though if the page is going to work equally well without them?
Well the thing is that the page is not necessarily going to work equally well without them. Leave out the wrong closing tag and one or more browsers may make a wrong assumption as to where that missing closing tag should go. If any browser does that then your page isn't going to display correctly in that browser. In order to make sure that all browsers place closing tags in exactly the same place we need to include those closing tags where we want them to be. This can also make it easier to fix problems when our page doesn't display correctly. Finding a validation error in your HTML where it says that you have a closing tag in the wrong place is an easy way of finding out that where you want a tag to close and where the browsers will assume that the closing tag ought to be are not the same and then you can rectify the code in your page before it goes live with a simple fix rather than spending hours trying to work out what you did wrong.
Including all the optional tags in your page source means that the browsers don't have to make any assumptions as to where those tags should be and if you have placed any of them in the wrong place a validator will soon tell you where you went wrong. Leave out any optional tags and if the browsers assume a different spot for the tags from where you thought they ought to be and you will have great difficulty figuring out why your page doesn't work.
So does it really come down to a choice between efficiency and maintainability with regard to optional tag?. The Google home page can get away with leaving out a lot of optional tags simply because the page is so simple to start with. Are more complex pages going to always give trould if we start leaving out optional tags? Well there is one simple way to get some of both. If we write our web page to start with including all the optional tags and test that then we will have an easy to maintain page where we know that all the optional tags are in the right place. What we then need to do is to remove all of those optional tags that can be safely removed before we upload the page to our site. This would best be done with an automated process that reads in the full source including optional tags and which drops those optional tags where they are in locations known to be safe. By automating the process we eliminate the possibility of accidentally deleting a tag that would break our page.
I have not as yet written a script to do such a conversion since with the few hundreds of thousands of page views that I get each month I don't consider the benefits to removing the optional tags to be great enough to make it worth doing. If I were going to create such a script though I'd look at removing such things as closing body and html tags that are immediately before the end of the file and removing closing paragraph tags that immediately precede and block level tag (opening or closing). I wouldn't look at removing and closing tags for inlone elements as there are browsers that allow such tags to be coded in the wrong order and which therefore would not add missing closing tags in the spot you'd necessarily expect.
This article written by Stephen Chapman, Felgall Pty Ltd.