Naser Mohd Baig Naser Mohd Baig - 2 years ago 70
HTML Question

Do spaces play a role in a CSS stylesheet or just for readability?

I have just started learning HTML with CSS, and I see many spaces in between the CSS stylesheet, I even tried removing those spaces and the sheet works perfectly. So what is the role of spaces?

Please check the example below:

body {
background-color: lightgrey;

h1 {
color: blue;

p {

has same function as

body{background-color: lightgrey;}
h1{color: blue;}


Answer Source

CSS is case sensitive, but CSS isn't space sensitive. There isn't a role for this, but generally is recommended use space. Why? Often is used this:

body {
   background-color: red;

It is called indentation, If you've a good indentation your code will be neater and more readable.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download