Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS Basics (2014) Basic Layout Backgrounds: Size and Position

Adriana Karlak
Adriana Karlak
1,450 Points

Is it a good or practice to always write shorthand code when you can?

On the one hand, it makes fewer lines of code and less typing on your part (which is a good thing) but on the other hand, it makes it harder to read and understand (which is a bad thing). So should I try to write in shorthand or not? Which way is the best for clean and readable code?

John Maxwell
John Maxwell
9,249 Points

If you understand how to read and understand shorthand notation, then it makes it easier to use it. It will also reduce time to write code, and the size of your files. I would just write however you are comfortable though.

1 Answer

I'd recommend you understand the long-form version, so that when you come to write short-hand, you understand which value means what. For example, for box-shadow you have something like this:

box-shadow: 0px 0px 18px 0px rgba(0,0,0,.16);

Knowing what each of those values represents, means you can quickly type out the numbers, without relying on 3rd-party tools.