3 ms·
Another best practice I have is to place a comment on each closing element, referring to the opening one. So,I have: <div class="CLASS"> CONTENTCONTENTCONTENT <
by Facens 16y ago
Another best practice I have is to place a comment on each closing element, referring to the opening one.
So,I have:
<div class="CLASS">
CONTENTCONTENTCONTENT
</div> <!-- .CLASS -->
When you have complex pages, with several nesting levels, this can save much, much time.
- robgough 16y agoIsnt there a danger that someone else working on your code might not respect that rule (or dare I say it, but maybe you're in a rush one day) and you don't update the comment when you update the class. Now you've got comments saying in correct things, and you risk all sorts of confusion. The same rule applies to commenting methods in code really, you don't comment what the code does exactly - just what the intention of the code is.
- Facens 16y agoThe time spent on keeping the code readable is never wasted :) Obviously, every developer must adopt this habit.