CSS

Common CSS Mistakes Should be Avoid

Common CSS Mistakes Should be Avoid

Using PX when it’s not Needed

Bad

				
					.class-name {
    padding: 10px 0px;
}
				
			

Good

				
					.class-name {
    padding: 10px 0;
}
				
			

Not Using Shorthand Properties

Bad

				
					.class-name {
    margin-top: 10px;
    margin-bottom: 10px;
    margin-left: 10px;
    margin-right: 10px;
}
				
			

Good

				
					.class-name {
    margin: 10px;
}
				
			

Using Font Fallback

Bad

				
					.class-name {
    font-family:Helvetica; 
}
				
			

Good

				
					.class-name {
    font-family:Arial, Helvetica, sans-serif; 
}
				
			

Repeating the Same code

Bad

				
					.class-name {
    margin: 10px;
    padding: 10px;
}

.other-class-name {
    margin: 10px;
    padding: 10px;
}
				
			

Good

				
					.class-name, .other-class-name {
    margin: 10px;
    padding: 10px;
}
				
			

Over Qualifying Selectors

Bad

				
					.navbar ul.menu li a {
   color: #000000
}
				
			

Good

				
					.menu a {
    color: #000000
}
				
			

Using Color Names

Bad

				
					.class-name {
    color: black
}
				
			

Good

				
					.class-name  {
    color: #000000
}
				
			
Share On: