TutsArena
The best web design tutorial resource for designers on the web!
10 Quick Ways To Keep Your Code Friendly
Keeping your code clean and well-documented is important to reduce errors and make your life easier, so is keeping your code friendly. We’ll show you 15 ways to keep your code browser, user and search engine friendly.
Coding errors are a major pain in the rear. So as a safe way to keep them to a minimum, or at least be able to fix them quickly if there is a problem, take these steps while writing your code. We’re pretty sure you won’t be sorry for going the extra mile.
-
Write good class and id names
Use short, descriptive names for your class and id attributes. This will save you time later and help you spot errors.
-
Use the right DOCTYPE
A basic step towards a standards-compliant website is using the correct DOCTYPE (document type declaration). Only then will your website render properly and validate.
-
Write clean code
Writing clean code will be easily maintainable and less of a pain for you and others.
-
Create unique link styles
Your links need to stand out so users aren’t left to guess what text is a link and what isn’t. Unless your users are on a scavenger hunt, it will save them frustration.
-
Use display:inline for floated elements
Avoid IE’s double float-margin and text indent bugs by using display:inline for floated elements.
-
Avoid going div-crazy
Try to use as few div elements as possible. “Div” means division thus, you don’t want your website to be a cookie cutter.
-
Use a background color
Don’t forget to set a background color! Failure to set a background color will allow users to see through your transparent body and see what their default background color is, (eg. red, yellow, blue) which could clash with your design.
-
Validate, validate, validate
Validating your code is the first stage of debugging and it can uncover minor bugs and prevent them from becoming festering problems.
-
Move scripts to the footer
Move scripts to your footer, if possible, to reduce the load times of your website.
-
Bundling your classes
Combine your CSS classes for skinnier code and to save yourself some time.




4 Comments
I really liked this post. Can I copy it to my site? Thank you in advance.
Feel free to post a copy of this article on your website, however, you must leave a link back to TemplateTuts. Thank you.
Although I must say theese are very basic things, that any real designer should think about on a daily basis, there seem to be people ignore alot of the above, I would however like to point out that moving ALL scripts to the end of your website, migth not always be the best solution. Things that could cause your website to render incorrectly, or in someway not make the site work as intended(it should work without javascript but there are sites requireing Javascripts) you should move thoose nessecary parts to the top.
One example of scripts that should always be at the bottom, is Google analytics code. It’s not nessecary, adn therefore it can wait until the very end to be loaded.
I agree Johan, sometimes you simply have to put a script toward the top of the code.
Add your comment - (need a gravatar?)