From the article: Comments on Comments
HTML comments can be a useful tool, but some people don't use them at all, and others only use them in certain situations. Share your best practices for HTML comments and find out what other designers do. Share Best Practices
Variety Comments
- I use comments to express my feelings about what i'm commenting on.Comments are important when you think about it.
- —Guest Christopher
When Do You Use HTML Comments?
- i put comment in html comments,because html is user friently...
- —Guest Raja
information
- It is used to give additional informatio regarding that particular line of code so that it would be understandable by a novice programmer
- —Guest guest archit
Reinventing the wheel
- Your comment about not reinventing the wheel hits home. I work for an internet publishing company in the Customer Support department. It requires that I have a fairly general familiarity with PHP, JS, CSS, HTML, the odd Perl script (oh, yeah), and, more recently, Smarty. Smarty is the most useful in terms of NOT reinventing the wheel because you cannot use PHP directly on the templates, you have to use plugins. This requires that we have an inventory of plugins and, if one site asks for functionality another site already has, all we in CS have to do is copy the plugin to the new site. In old sites, though, where PHP, JS, and HTML are slapped into the templates wherever they're needed, comments make a world of difference to finding the functionality you need. Sadly, some of folks haven't/don't use comments and we in CS end up wasting time looking for it or else reinventing the wheel (and then we make sure to add comments!).
- —kes_web_cnc
Start and end of a loop
- I put HTML comments at the end of a loop statement. Using PHP, you can do this with # or // before the line of text which you consider a comment. In my example, if I put an if($a==$b){ at the start of a section of code, then I would not only put } at the end of the code, but I would expand it to } //END if($a==$b){ to signify that this is the end of that if/then statement. Before using this method, I would need to start adding and subtracting all of the open ({) and close tags (}) just to find what I was looking for. Now, I just search for the text memo that includes the opening line of code.
- —Guest Bryce
Variable Section
- Any variable section of the page that may be needed to update frequently, so that accidentally page doesn't loose any other important part. Also where any change in future may be required.
- —Guest Kapil
Each section and any unusual function
- I label each section, each div, each include, and wherever something unobvious is happening. It makes the work inheritable, and helps me, too, whenever I go back to make changes later.
- —Guest Linda
Section Marking
- I use HTML comments to demark sections of the page. Since I'm frequently interspersing PHP and XHTML while creating page templates, I find it easier to determine the section of the page I'm on by using the comments to mark the beginning and end of the section.
- —dbmartin
Problem Solving
- I may use them extensively in the stylesheet(s) when I'm first building a site, mostly for problem solving and to explain to myself any unfamiliar chunks of code I have used. If I have a CSS layout issue, I will comment out large/recent sections of code until I eventually identify where the problem lies. I may leave the odd reminder in place when I 've finished, but will remove most.
- —NajArt
page information
- I put comments in both my html and my xml at the top of the document to include information about the page. I include things like the author, developer, date edited, and what was changed. It's very helpful to see at least the last few edits right there at the top of the page.
- —Guest maos

