What are some mistakes people make when they start learning HTML, CSS and JavaScript?

Web Development Best Practices: A Checklist for Clean Code

Using id instead of class names

Many beginners are tending to write CSS using id names instead of CSS class names. We should always aim to reuse the code as much as possible. By using id names we are applying styles only to that particular div rather than sharing the styles which are common to div s having the same class name.

Do read this article which gives a practical approach to maintainable CSS.

Infographic: using id names in CSS instead of Class names

Not using CSS shorthand

Using CSS shorthand will come as a second nature by practice. Until then we need to force ourselves to write CSS in the right way. While working on a large project, we will notice that by using shorthand properties the number of code lines in CSS file will be reduced reasonably.

CSS shorthand comparison example

CSS Measurements

0px is just a 0. There is no need to mention if it is a px or em. Following a standard measurement throughout the project is important. Be it px or rem, it should be followed by all for the project. Using relative values are encouraged more than absolute values.

HTML Structure

Proper html structure is more important to an optimized application. We should use HTML5 tags like aside and wherever it is required. Not overusing tags is also important and it comes only out of practice.

Wrapping div inside div and going multilevel is one of the mistakes learners tend to make. We can keep our HTML structure simple and short wherver possible. Using HTML5 tags are semantic over the general tag and has advantages of its own.

HTML5 semantic layout diagram

Class specificity

Sticking to three levels of selectors is considerable. Avoid an overdose of selectors.

Commenting

Commenting out the code helps to understand the logic and helps our peers understand when they look at the code base.

Media queries

It is always recommended to follow a mobile-first approach. Do not mix min-width and max-width. Sticking to clear breakpoints, similar to Twitter Bootstrap, is ideal.

Checking console & Developer Tools

One should learn to use Chrome web developer tools effectively to audit the application and resolve common jQuery errors.

Using Chrome web developer tools for auditing

Comments

Popular posts from this blog

The Ultimate Guide to AI/ML Hosting and Choosing the Best Platform

Best AI Tools for Women in 2025

Why Visakhapatnam is a Data Center hub: Guide to Datacenter Site Evaluation