3 Ways to keep your code clean
There are always people who don’t care if their code is clean, for them what really matters is the code to work. But why you should bother to have or to clean your code? As a web developer at Blueprint I try to keep my code clean and simple because messy code is waste of time. There will be web developers who will go after you to add content or pages and they can’t find the proper CSS (Cascading Style Sheets) code because someone have written a messy code.
Having Proper Indentation
Indentation has no effect of how the page is rendered but has a huge effect on how web developers read the code. Usually coders indent by one tab or 2 3 spaces when they are starting a new element that is child element of the tag above.
There are no indentation rules, every developer create their own rules. If you create your own rules or you do how your teacher show you, try to be consistent in every code that you write.
Stop creating Class for HTML tags that already exist
My first days as a web designer I use to create a class for everything. But why I should create new code for something that is already there and waiting to be used? Most of new designers don’t know, or for them is much easier. If you have this habit try to get rid of it.
Bad code .second-header { color:#330099; }
Good code #content h2 { color:#330099; }
Organize you’re CSS
When creating a new CSS page for a website try to order it. If is possible try to keep the code in a logic order. Try to write the code in the order of the web page. For example keep the header rules first, than the body and the last one should be the footer. You could also comment when the body rules start or end, when the navigation rules start and ends. This way, when you go back later to change some rules you will know that the footer rules will be the last ones in the CSS page.
By: Mihai
The comments are closed.
No reviews yet