As time passes by and a repetitive task becomes even more repetitive bad habits begin to creep in. Before you know it the ‘bad habit’ is no longer a bad habit; it has become normal procedure.
Sometimes you can check yourself and realise you are doing something wrong and fix it. Other times you just need a gentle nudge.
Yesterday I got nudged
If you are hard/hand coding websites you will understand what a <DIV> tag is. You will also know that the more complicated a web page becomes, the more closing </DIV> tags you are going to need to keep the code clean and to ensure the page is displaying correctly.
Yesterday I was watching a video which reminded that adding a comment to a closing </DIV> tag is considered “best practice” when writing HTML.
</DIV><!--end of class-->
Why is this a good thing to do?
If you are building websites using css you will know that the simplest of pages can consist of mutiple opening and closing <DIV> tags. Each one controlling a particular element of the page. Whilst it is very easy to see where a CLASS or ID opens, it is not always so easy to know where it closes. If you add the closing comment to the closing </DIV> tag before you add any content between the two tags, it will help you to identify exactly what is happening within the page.
This may not sound like something you could benefit from, but believe me, it could save you a lot of time in the future. Just because a webpage makes sense to you now, doesn’t mean it will in twelve or even six months time.
<DIV> overload is something I have suffered from in the past and stripping down a page to found out which <DIV> ends which piece of code is not the best way to pass time!
If you are new to coding get used to adding an end comment to your <DIV>’s and keep up with the practice.
If you have forgotten or do not know how to do this, here is a reminder:
<DIV CLASS="class">HTML code and other bumpf goes here</DIV><!--end of class-->
THIS IS THE IMPORTANT PART AND COULD SAVE YOU HOURS OF HEAD SCRATCHING AND CODE DISSESCTING!
</DIV><!--end of class-->




