Created
July 9, 2014 01:10
-
-
Save ryon/8820be10292935567622 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
css { | |
should-look: like-this; | |
/* one space after the selector */ | |
/* opening brace on the same line */ | |
/* 4-space indent */ | |
/* closing brace on its own line */ | |
/* one blank line between rules */ | |
} | |
.one-liners { can-look: like-this; } /* but only do this if the rule has only one property and it's unlikely to gain more */ | |
grouped, | |
selectors { | |
go: 'on separate lines'; /* single quotes around strings in CSS and JS, double quotes for HTML attributes */ | |
} | |
colors { | |
use: #b4d455; /* lowercase alpha digits */ | |
use: #cdc; /* three-digit hex if it's available */ | |
use: white; /* keyword if it's common */ | |
} | |
sort { | |
all: properties; | |
in: alphabetical; | |
order: for-sanity; | |
} | |
div { | |
/* always use the shortest notation possible for box-model lengths */ | |
/* remember that bottom will copy top and left will copy right, unless otherwise indicated */ | |
/* also, leave units off zero values */ | |
border-radius: 2px; /* not 2px 2px 2px 2px */ | |
border-width: 1px 0; /* not 1px 0px 1px 0px */ | |
margin: 10px 20px 30px; /* not 10px 20px 30px 20px; */ | |
padding: 10px 20px 30px 40px; /* write out all four only if necessary */ | |
} | |
div { | |
/* sometimes it's more readable to declare an all-around value and then "tweak" it */ | |
/* this makes the outlier stand out better */ | |
padding: 10px; | |
padding-right: 0; | |
/* not padding: 10px 0 10px 10px */ | |
/* but this is not a hard and fast rule */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another one:
background
, where there are a bunch of values that you might be inadvertently overwriting by omission. Use the individual properties instead to avoid cascade weirdness.