-
Notifications
You must be signed in to change notification settings - Fork 0
Code Formatting CSS
Adroaldo de Andrade edited this page Sep 29, 2014
·
4 revisions
- Do not use tabs, use four spaces instead
- Indentation should have 4 spaces
- Do not leave space at end of line
- At end of file leave a new line
- Leave a new line before each selector
- One selector per line, one rule per line
- List related properties together
- Zero does not need unit
- Avoid to use ID's
Good
.red-rouded-box { ... }Bad
.alert-message { ... }Good
/* Primary header */
header { ... }
/* Featured footer */
footer { ... }
/* Buttons */
.button { ... }Bad
header { ... }
footer { ... }
.button { ... }Good
img {
margin: 5px 10px;
background-color: #CCC;
color: #FA8;
}
button {
padding-left: 20px;
}Bad
img {
margin-top: 5px;
margin-right: 10px;
margin-bottom: 5px;
margin-left: 10px;
background-color: #CCCCCC;
color: #FFAA88;
}
button {
padding: 0 0 0 20px;
}Good
a,
.btn {
background-color: #CCC;
color: #0C0;
padding: 5px;
}Bad
a,.btn{background-color: #CCC;color: #0C0;padding: 5px;}Good
.rounded-border-box {
background: #eee;
border: 1px solid #EEE;
border-radius: 5px;
}Bad
.news {
background: #eee;
border: 1px solid #EEE;
border-radius: 5px;
}
.events {
background: #eee;
border: 1px solid #EEE;
border-radius: 5px;
}Good
.shadown-box {
background: -webkit-linear-gradient(#CCC, #045);
background: -moz-linear-gradient(#CCC, #045);
background: linear-gradient(#CCC, #045);
-webkit-box-shadow: 10px 10px 5px #888;
-moz-box-shadow: 10px 10px 5px #888;
box-shadow: 10px 10px 5px #888;
}Bad
.shadown-box {
background: -webkit-linear-gradient(#CCC, #045);
background: -moz-linear-gradient(#CCC, #045);
background: linear-gradient(#CCC, #045);
-webkit-box-shadow: 10px 10px 5px #888;
-moz-box-shadow: 10px 10px 5px #888;
box-shadow: 10px 10px 5px #888;
}