Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a need to put a space after colon in CSS declaration?

Tags:

css

I am really bad in CSS,
I often see people using colon + space :-

a {color: red;}  /* colon followed by space */
a {color:red;}   /* instead of this */

Both still does the same (at least browser still renders it the same). So, is this just a code formatting preference?
(Does it carry any hidden meaning ?)

like image 815
ajreal Avatar asked Dec 08 '11 18:12

ajreal


People also ask

Does CSS need spaces?

Sometimes Important: SpacesThere are just a few places that spaces are important in CSS. One of the most important is in selectors. One space in a selector means you're selecting descendants of the previous part of the selector. The selector body p means “select p elements that are descendants of the body element”.

How do you put a space after a colon in HTML?

If you find yourself in html needing a space you can always insert   In your situation you can add a space, but only one. Additional spaces are ignored.

What is a CSS declaration?

A CSS declaration block is an ordered collection of CSS properties and values. It is represented in the DOM as a CSSStyleDeclaration . Each property and value pairing is known as a CSS declaration.


1 Answers

It is not necessary, it's just a readability preference.

like image 103
Rion Williams Avatar answered Oct 18 '22 23:10

Rion Williams