Last Updated: February 25, 2016
·
1.277K
· krzochalski

Be a clean CSS coder (part one)

We all have struggled with somebody else's CSS code. I am doing now, so I want to share my suggestions, observations.

There are many ways writes to write CSS code. Let me show you how to write it so everyone will instantly read it, with pleasure.

.class {
  property: value;
}

Names

Use a name that describes what you are styling. Do not give a name "Snoopie" for a form button. Make it simple, short and above all, descriptive.

Indents

Remember about them. Some people use many values, but two spaces are just perfect.

Space

After you write a property, it is good to leave a space before you write a value. It is much more readable, at least it is what I think.

Consistency

Whatever you do, do it repeatedly. When you define your coding style, be consistent and always use the same style. Always.

4 Responses
Add your response

Hi. Do you put a ; after a block? Why?

over 1 year ago ·

@fernandoperigolo my mistake, sorry
now it is correct

over 1 year ago ·

@krzochalski, ok, no problem. Waiting for the second part. See you.

over 1 year ago ·

I am glad that someone read this carefully and gave me feedback about the error. Next part tomorrow

over 1 year ago ·