Skip to content

Commit 4198f0d

Browse files
committed
Update README.md
1 parent 1a35be1 commit 4198f0d

File tree

1 file changed

+151
-78
lines changed

1 file changed

+151
-78
lines changed

README.md

+151-78
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Configure your text editor to adhere to the above. At the bare minimum configure
8484

8585
#### Sublime Text
8686

87-
If you use Sublime Text editor (and you should) then install [this package](https://github.com/SublimeText/TrailingSpaces) and use these settings in your **Settings - User** file which can be found here: **Sublime Text -> Preferences -> Settings User**:
87+
If you use Sublime Text editor then install [this package](https://github.com/SublimeText/TrailingSpaces) and use these settings in your **Settings - User** file which can be found here: **Sublime Text -> Preferences -> Settings User**:
8888

8989
```
9090
"tab_size": 2,
@@ -128,83 +128,90 @@ For reference here is an anatomy of a rule set:
128128
### Formatting rules
129129

130130
- Class names to use BEM notation, see [Naming Conventions -> BEM](#bem), where BEM isn't used then hyphen delimited class names are to be used.
131-
- Use one discrete selector per line in multi-selector rule sets, e.g.
131+
- Use one discrete selector per line in multi-selector rule sets.
132132

133-
```
133+
**Good**
134+
```scss
134135
.error,
135136
.success {
136137
...
137138
}
138139
```
139-
*not*
140-
```
140+
141+
**Bad**
142+
```scss
141143
.error, .success {
142144
...
143145
}
144146
```
145-
- Include a single space before the opening brace of a rule set, e.g.
146-
147-
```
147+
- Include a single space before the opening brace of a rule set.
148+
149+
**Good**
150+
```scss
148151
.error,
149152
.success {
150153
...
151154
}
152155
```
153-
*not*
154-
```
156+
157+
**Bad**
158+
```scss
155159
.error,
156160
.success{
157161
...
158162
}
159163
```
160-
- Place the closing brace of a rule set in the same column as the first character of the rule set, e.g.
164+
- Place the closing brace of a rule set in the same column as the first character of the rule set.
161165

162-
```
166+
**Good**
167+
```scss
163168
.error,
164169
.success {
165170
...
166171
}
167172
```
168-
*not*
169-
```
173+
174+
**Bad**
175+
```scss
170176
.error,
171177
.success {
172178
...}
173179
```
174-
- Properties within rule sets should each reside on their own line except for single-line declaration rule sets, e.g.
180+
- Properties within rule sets should each reside on their own line.
175181

176-
```
182+
**Good**
183+
```scss
177184
p {
178185
margin: 0;
179186
padding: 0;
180187
}
181188
```
182-
*not*
183-
```
189+
190+
**Bad**
191+
```scss
184192
p {margin: 0; padding: 0;}
185193
```
186-
*single-line declaration rule sets allowed, e.g.*
187-
```
188-
p {margin: 0;}
189-
```
190-
- Use one level of indentation for each declaration, e.g.
194+
- Use one level of indentation for each declaration.
191195

192-
```
196+
**Good**
197+
```scss
193198
.error {
194199
border: 0;
195200
margin: 0;
196201
}
197202
```
198-
*not*
199-
```
203+
204+
**Bad**
205+
```scss
200206
.error {
201207
border: 0;
202208
margin: 0;
203209
}
204210
```
205-
- Separate each rule set by a blank line, e.g.
211+
- Separate each rule set by a blank line.
206212

207-
```
213+
**Good**
214+
```scss
208215
.error {
209216
border: 0;
210217
margin: 0;
@@ -215,8 +222,9 @@ For reference here is an anatomy of a rule set:
215222
margin: 0;
216223
}
217224
```
218-
*not*
219-
```
225+
226+
**Bad**
227+
```scss
220228
.error {
221229
border: 0;
222230
margin: 0;
@@ -226,77 +234,142 @@ For reference here is an anatomy of a rule set:
226234
margin: 0;
227235
}
228236
```
229-
- Include a single space after the colon of a property, e.g. `margin: 0;` *not* `margin:0;`.
230-
- Use lowercase and shorthand hex values, e.g. `#aaa` *not* `#aaaaaa`.
231-
- Always use the shortest shorthand form possible for properties that support it, e.g. `margin: 1px;` *not* `margin: 1px 1px 1px 1px;`.
237+
- Include a single space after the colon of a property.
238+
239+
**Good**
240+
```scss
241+
margin: 0;
242+
```
243+
**Bad**
244+
```scss
245+
margin:0;
246+
```
247+
- Use lowercase and shorthand hex values.
248+
249+
**Good**
250+
```scss
251+
#aaa
252+
```
253+
**Bad**
254+
```scss
255+
#aaaaaa
256+
```
257+
- Always use the shortest shorthand form possible for properties that support it.
258+
259+
**Good**
260+
```scss
261+
margin: 1px;
262+
```
263+
**Bad**
264+
```scss
265+
margin: 1px 1px 1px 1px;
266+
```
232267
- Always use double quotes, specifically for:
233268
- String literals e.g. `content: "";`.
234269
- `url()` e.g. `background: url("img/logo.png");`.
235270
- Attribute values in selectors e.g. `input[type="checkbox"]`.
236-
- Where allowed, avoid specifying units for zero-values, e.g. `margin: 0;` *not* `margin: 0px;`.
237-
- Commas in lists should be followed by a space, e.g. `color: rgba(0, 0, 0, 0.1);` *not* `color: rgba(0,0,0,0.1);`.
238-
- Include a space before `!important` keyword, e.g. `padding: 10px !important;` *not* `padding: 10px!important;`.
239-
- Property values; `@extend`, `@include`, and `@import` directives; and variable declarations should always end with a semicolon, e.g. `color: #fff;` *not* `color: #fff`.
240-
- Parentheses should not be padded with spaces, e.g. `@include box-shadow(0 2px 2px rgba(0, 0, 0, .2));` *not* `@include box-shadow( 0 2px 2px rgba( 0, 0, 0, .2 ) );`.
241-
- When a decimal mark is needed always include the zero, e.g. `0.25rem` *not* `.25rem`.
242-
- Don't write trailing zeros for numeric values with a decimal point, e.g. `margin: 0.5em;` *not* `margin: 0.500em;`.
243-
- URLs should not contain protocols or domain names, e.g. `background: url('assets/image.png');` *not* `background: url('https://example.com/assets/image.png');`.
244-
- Indent rule sets to mirror the DOM, e.g.
245-
246-
```
247-
.widget,
248-
.widget-2 {
249-
padding: 1em;
250-
border: 1px solid #bada55;
251-
background-color: #c0ffee;
252-
}
271+
- Where allowed, avoid specifying units for zero-values.
272+
273+
**Good**
274+
```scss
275+
margin: 0;
276+
```
277+
**Bad**
278+
```scss
279+
margin: 0px;
280+
```
281+
- Commas in lists should be followed by a space.
282+
283+
**Good**
284+
```scss
285+
color: rgba(0, 0, 0, 0.1);
286+
```
287+
**Bad**
288+
```scss
289+
color: rgba(0,0,0,0.1);
290+
```
291+
- Include a space before `!important` keyword.
292+
293+
**Good**
294+
```scss
295+
padding: 10px !important;
296+
```
297+
**Bad**
298+
```scss
299+
padding: 10px!important;
300+
```
301+
- Property values; `@extend`, `@include`, and `@import` directives; and variable declarations should always end with a semicolon.
302+
303+
**Good**
304+
```scss
305+
color: #fff;
306+
```
307+
**Bad**
308+
```scss
309+
color: #fff
310+
```
311+
- Parentheses should not be padded with spaces.
312+
313+
**Good**
314+
```scss
315+
@include box-shadow(0 2px 2px rgba(0, 0, 0, .2));
316+
```
317+
**Bad**
318+
```scss
319+
@include box-shadow( 0 2px 2px rgba( 0, 0, 0, .2 ) );
320+
```
321+
- When a decimal mark is needed always include the zero.
322+
323+
**Good**
324+
```scss
325+
0.25rem
326+
```
327+
**Bad**
328+
```scss
329+
.25rem
330+
```
331+
- Don't write trailing zeros for numeric values with a decimal point.
253332

254-
.widget__heading {
255-
font-size: 1.5rem;
256-
line-height: 1;
257-
font-weight: bold;
258-
color: #bada55;
259-
}
333+
**Good**
334+
```scss
335+
margin: 0.5em;
336+
```
337+
**Bad**
338+
```scss
339+
margin: 0.500em;
340+
```
341+
- `url`s should not contain protocols or domain names.
342+
343+
**Good**
344+
```scss
345+
background: url('assets/image.png');
346+
```
347+
**Bad**
348+
```scss
349+
background: url('https://example.com/assets/image.png');
260350
```
261-
Here we can see that `.widget__heading` must be a child of `.widget` as we have indented the `.widget__heading` rule set one level deeper than `.widget`, as it is in the DOM. This is useful information to developers that can now be gleaned just by a glance at the indentation of our rule sets.
262351

263352
### Declaration order
264353

265-
Declarations should be ordered in relevance, **NOT** alphabetically.
354+
Declarations should be ordered alphabetically.
266355

267356
Example:
268357

269358
```
270359
.selector {
271-
/* Positioning */
272-
position: absolute;
273-
z-index: 10;
274-
top: 0;
275-
right: 0;
360+
background-color: #000;
276361
bottom: 0;
277-
left: 0;
278-
279-
/* Display & Box Model */
280-
display: inline-block;
281-
overflow: hidden;
282362
box-sizing: border-box;
283-
width: 100px;
284-
height: 100px;
285-
padding: 10px;
286-
border: 10px solid #333;
287-
margin: 10px;
288-
289-
/* Other */
290-
background-color: #000;
291363
color: #fff;
364+
display: inline-block;
292365
font-family: sans-serif;
293366
font-size: 1em;
367+
height: 100px;
294368
text-align: right;
369+
width: 100px;
295370
}
296371
```
297372

298-
*Comments do not need to be used to label each group of declarations like above*.
299-
300373
### Exceptions and slight deviations
301374

302375
Long, comma-separated property values—such as collections of gradients or shadows can be arranged across multiple lines in an effort to improve readability and produce more useful diffs. Each value after the first should be indented so that it starts at the same level as the first value e.g.

0 commit comments

Comments
 (0)