Status: draft proposal, not for deployment
Here are some coding conventions to make life easier - both for those who develop the framework, and for those who use it.
Do not use cryptic or meaningless names for your HTML classes:
<p class="style1">Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>
<p class="caption">Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>
Rule of thumb: Is my HTML human-readable (by a stranger)?
An ID is a unique identifier for an HTML element. There should only be one element on a page with a given ID. Classes can be applied to multiple elements.
It is sometimes tempting to give every element a class or an ID. Please don't - brush up on your selectors instead.
An element can have more than one class applied to it. This allows you to have a really tight cascade, and reduces the number of classes you need.
<p class="footnote legal">Aliquam eget neque et ipsum sodales tincidunt.</p>
.footnote {font-size: 0.9em;} .legal {color: #333;} .footnote.legal {font-style: italic; text-align: right;}
The paragraph in this example would inherit all of the above properties. Note also that your .footnote.legal selector has more weight than the others.
Please write all variables, html element classes, URLs and so on, in the same format:
var my_names_array = new Array("Bob","Julie","Pat"); var first_name = my_names_array[0];
Can a complete stranger understand your code? No? Have you followed the rules above? Yes? Then leave a comment to explain what is going on.
With complex nested markup it is also a good idea to use comments to show which closing tag belongs where:
<div class="grid"> <div class="column"> First column </div><!-- /1st column--> <div class="column span_three"> Second column </div><!-- /2nd column--> <div class="column last"> Third column </div><!-- /3rd column--> </div><!-- /grid-->
Tables are great for tabular data - where you need to show relationships between data sets - but should not be used for page layout.
Less is best.