I have been asked to create guidelines for review CSS, JS and HTML. I know there are coding guidelines for JS but I don't know any about HTML and CSS. To review JS I will certainly follow those guidelines and mention them. But what about CSS and HTML? Apart from logical errors and indentation issues, are there any specific things I need to check when I review markup and or CSS?
|
Some things to look for:
|
||||
|
One of important elements of a good style in HTML is progressive enhancement. This means that HTML layout will render good even without CSS or JavaScript. Then, once JS/CSS are processed, it will look better (e.g. old-style HTML This also has to do with non-intrusive markup. Instead of Same with JavaScript. Instead of |
|||
|
As far as HTML goes, I always make a point to have hierarchies and indentation in my files. For example, if I have a bunch of divs:
I suppose that's fairly obvious to most who create layouts and templates, but more often than not I just see garbled HTML that has no structural hierarchy whatsoever, making it difficult to read for another person. I guess coming from a more CS background, this is something that sticks in my mind. The same goes for CSS as well. Let's say you're styling a div:
Indentation makes it a lot easier to read through quickly when you're used to another language mixed in like PHP/Ruby/Whatever. Again, it depends on how you work best, but when others read my HTML, I like to make it really organized :). Also, as said above, it is always a great idea to name your CSS classes and ids relevant names to your layout, especially when it gets hairy (much like naming variables and methods in other languages). Something else to watch out for is the dreaded "guess and check" of margins, paddings and other alignment issues. Something I often try to avoid is putting negative numbers in my margins and paddings. It can get confusing if you did not make the layout yourself and if you want to come back to it later and modify it, you might have to overhaul it. In my opinion it is always a good idea to not try anything hokey or "kludgy" in CSS, even if it looks nice; there's usually a better way to do it, even if you have to restructure your CSS! |
|||
|
For Javascript I would always want it to validate with JSLint, i can think of so many bugs that JSLint catches that not using it is just crazy. |
|||
|
I came across this standards document that I rather liked. I'll also echo what was said about progressive enhancement. In general, if someone else writes the HTML/CSS, you should be able to look at it later down the line and be pleasantly surprised how not-bad the markup is and should be able to make simple style tweaks easily and efficiently. |
|||
|