Search code examples
csssyntaxlanguage-design

Why does CSS use colons ":" in rules?


CSS properties use no spaces so why isn't the first space in the rule used as a separator between the property and the value?

Here's an example:

enter image description here


Solution

  • Why not remove the curly-braces as well and let indentation dictate the structure? That would be even cleaner.

    However, sometimes better syntax is not about removing everything you can imagine, you often need to keep something to keep the syntax clear as well. A syntax that is more clear expresses the intention in a better way than a cleaner, more implicit syntax. It's harder to make mistakes with an explicit syntax, and easier to spot those mistakes.

    In your two examples, I find the first one a lot easier to understand, because the key and the value are clearly, explicitly separated.