├── .csscomb.json ├── .editorconfig ├── .gitignore ├── .npmrc ├── .yaspellerrc ├── abbreviations.md ├── index.html ├── package.json ├── readme.md └── style.css /.csscomb.json: -------------------------------------------------------------------------------- 1 | { 2 | "exclude": [ 3 | ".git/**", 4 | "node_modules/**" 5 | ], 6 | "remove-empty-rulesets": true, 7 | "always-semicolon": true, 8 | "block-indent": " ", 9 | "color-case": "lower", 10 | "element-case": "lower", 11 | "color-shorthand": false, 12 | "eof-newline": true, 13 | "leading-zero": true, 14 | "quotes": "double", 15 | "sort-order-fallback": "abc", 16 | "space-before-colon": "", 17 | "space-after-colon": " ", 18 | "space-before-combinator": " ", 19 | "space-after-combinator": " ", 20 | "space-between-declarations": "\n", 21 | "space-before-opening-brace": " ", 22 | "space-after-opening-brace": "\n", 23 | "space-before-selector-delimiter": "", 24 | "space-after-selector-delimiter": "\n", 25 | "space-before-closing-brace": "\n", 26 | "tab-size": 2, 27 | "unitless-zero": true, 28 | "vendor-prefix-align": true, 29 | "strip-spaces": true, 30 | "sort-order": [ 31 | [ 32 | "content", 33 | "position", 34 | "top", 35 | "right", 36 | "bottom", 37 | "left", 38 | "z-index" 39 | ], 40 | [ 41 | "display", 42 | "-webkit-flex", 43 | "-ms-flex", 44 | "flex", 45 | "-webkit-flex-grow", 46 | "flex-grow", 47 | "-webkit-flex-shrink", 48 | "flex-shrink", 49 | "-webkit-flex-basis", 50 | "flex-basis", 51 | "-webkit-flex-flow", 52 | "flex-flow", 53 | "-webkit-flex-direction", 54 | "-ms-flex-direction", 55 | "flex-direction", 56 | "-webkit-flex-wrap", 57 | "flex-wrap", 58 | "-webkit-justify-content", 59 | "justify-content", 60 | "-webkit-align-content", 61 | "align-content", 62 | "-webkit-align-items", 63 | "align-items", 64 | "-webkit-order", 65 | "-ms-flex-order", 66 | "order", 67 | "-webkit-align-self", 68 | "align-self", 69 | "float", 70 | "clear", 71 | "-webkit-box-sizing", 72 | "-moz-box-sizing", 73 | "box-sizing", 74 | "width", 75 | "min-width", 76 | "max-width", 77 | "height", 78 | "min-height", 79 | "max-height", 80 | "margin", 81 | "margin-top", 82 | "margin-right", 83 | "margin-bottom", 84 | "margin-left", 85 | "padding", 86 | "padding-top", 87 | "padding-right", 88 | "padding-bottom", 89 | "padding-left", 90 | "overflow", 91 | "-ms-overflow-x", 92 | "overflow-x", 93 | "-ms-overflow-y", 94 | "overflow-y", 95 | "-webkit-overflow-scrolling" 96 | ], 97 | [ 98 | "list-style", 99 | "list-style-position", 100 | "list-style-type", 101 | "list-style-image", 102 | "border-collapse", 103 | "border-spacing", 104 | "table-layout", 105 | "empty-cells", 106 | "caption-side", 107 | "font", 108 | "font-weight", 109 | "font-size", 110 | "line-height", 111 | "font-family", 112 | "vertical-align", 113 | "text-align", 114 | "direction", 115 | "color", 116 | "text-transform", 117 | "text-decoration", 118 | "font-style", 119 | "font-variant", 120 | "font-size-adjust", 121 | "font-stretch", 122 | "font-effect", 123 | "font-emphasize", 124 | "font-emphasize-position", 125 | "font-emphasize-style", 126 | "font-smooth", 127 | "-webkit-text-align-last", 128 | "-moz-text-align-last", 129 | "-ms-text-align-last", 130 | "text-align-last", 131 | "letter-spacing", 132 | "word-spacing", 133 | "white-space", 134 | "text-emphasis", 135 | "text-emphasis-color", 136 | "text-emphasis-style", 137 | "text-emphasis-position", 138 | "text-indent", 139 | "-ms-text-justify", 140 | "text-justify", 141 | "-ms-writing-mode", 142 | "text-outline", 143 | "text-wrap", 144 | "-ms-text-overflow", 145 | "text-overflow", 146 | "text-overflow-ellipsis", 147 | "text-overflow-mode", 148 | "text-orientation", 149 | "-ms-word-wrap", 150 | "word-wrap", 151 | "-ms-word-break", 152 | "word-break", 153 | "-moz-tab-size", 154 | "-o-tab-size", 155 | "tab-size", 156 | "-webkit-hyphens", 157 | "-moz-hyphens", 158 | "hyphens", 159 | "unicode-bidi", 160 | "columns", 161 | "column-count", 162 | "column-fill", 163 | "column-gap", 164 | "column-rule", 165 | "column-rule-color", 166 | "column-rule-style", 167 | "column-rule-width", 168 | "column-span", 169 | "column-width", 170 | "text-shadow", 171 | "page-break-after", 172 | "page-break-before", 173 | "page-break-inside" 174 | ], 175 | [ 176 | "background", 177 | "background-color", 178 | "background-image", 179 | "background-repeat", 180 | "background-position", 181 | "-ms-background-position-x", 182 | "background-position-x", 183 | "-ms-background-position-y", 184 | "background-position-y", 185 | "-webkit-background-size", 186 | "-moz-background-size", 187 | "-o-background-size", 188 | "background-size", 189 | "-webkit-background-clip", 190 | "-moz-background-clip", 191 | "background-clip", 192 | "background-origin", 193 | "background-attachment", 194 | "box-decoration-break", 195 | "background-blend-mode", 196 | "border", 197 | "border-width", 198 | "border-style", 199 | "border-color", 200 | "border-top", 201 | "border-top-width", 202 | "border-top-style", 203 | "border-top-color", 204 | "border-right", 205 | "border-right-width", 206 | "border-right-style", 207 | "border-right-color", 208 | "border-bottom", 209 | "border-bottom-width", 210 | "border-bottom-style", 211 | "border-bottom-color", 212 | "border-left", 213 | "border-left-width", 214 | "border-left-style", 215 | "border-left-color", 216 | "-webkit-border-radius", 217 | "-moz-border-radius", 218 | "border-radius", 219 | "-webkit-border-top-left-radius", 220 | "-moz-border-radius-topleft", 221 | "border-top-left-radius", 222 | "-webkit-border-top-right-radius", 223 | "-moz-border-radius-topright", 224 | "border-top-right-radius", 225 | "-webkit-border-bottom-right-radius", 226 | "-moz-border-radius-bottomright", 227 | "border-bottom-right-radius", 228 | "-webkit-border-bottom-left-radius", 229 | "-moz-border-radius-bottomleft", 230 | "border-bottom-left-radius", 231 | "-webkit-border-image", 232 | "-moz-border-image", 233 | "-o-border-image", 234 | "border-image", 235 | "-webkit-border-image-source", 236 | "-moz-border-image-source", 237 | "-o-border-image-source", 238 | "border-image-source", 239 | "-webkit-border-image-slice", 240 | "-moz-border-image-slice", 241 | "-o-border-image-slice", 242 | "border-image-slice", 243 | "-webkit-border-image-width", 244 | "-moz-border-image-width", 245 | "-o-border-image-width", 246 | "border-image-width", 247 | "-webkit-border-image-outset", 248 | "-moz-border-image-outset", 249 | "-o-border-image-outset", 250 | "border-image-outset", 251 | "-webkit-border-image-repeat", 252 | "-moz-border-image-repeat", 253 | "-o-border-image-repeat", 254 | "border-image-repeat", 255 | "outline", 256 | "outline-width", 257 | "outline-style", 258 | "outline-color", 259 | "outline-offset", 260 | "-webkit-box-shadow", 261 | "-moz-box-shadow", 262 | "box-shadow", 263 | "-webkit-transform", 264 | "-moz-transform", 265 | "-ms-transform", 266 | "-o-transform", 267 | "transform", 268 | "-webkit-transform-origin", 269 | "-moz-transform-origin", 270 | "-ms-transform-origin", 271 | "-o-transform-origin", 272 | "transform-origin", 273 | "-webkit-backface-visibility", 274 | "-moz-backface-visibility", 275 | "backface-visibility", 276 | "-webkit-perspective", 277 | "-moz-perspective", 278 | "perspective", 279 | "-webkit-perspective-origin", 280 | "-moz-perspective-origin", 281 | "perspective-origin", 282 | "-webkit-transform-style", 283 | "-moz-transform-style", 284 | "transform-style", 285 | "visibility", 286 | "cursor", 287 | "opacity", 288 | "-webkit-filter", 289 | "filter" 290 | ], 291 | [ 292 | "-webkit-transition", 293 | "-moz-transition", 294 | "-ms-transition", 295 | "-o-transition", 296 | "transition", 297 | "-webkit-transition-delay", 298 | "-moz-transition-delay", 299 | "-ms-transition-delay", 300 | "-o-transition-delay", 301 | "transition-delay", 302 | "-webkit-transition-timing-function", 303 | "-moz-transition-timing-function", 304 | "-ms-transition-timing-function", 305 | "-o-transition-timing-function", 306 | "transition-timing-function", 307 | "-webkit-transition-duration", 308 | "-moz-transition-duration", 309 | "-ms-transition-duration", 310 | "-o-transition-duration", 311 | "transition-duration", 312 | "-webkit-transition-property", 313 | "-moz-transition-property", 314 | "-ms-transition-property", 315 | "-o-transition-property", 316 | "transition-property", 317 | "-webkit-animation", 318 | "-moz-animation", 319 | "-ms-animation", 320 | "-o-animation", 321 | "animation", 322 | "-webkit-animation-name", 323 | "-moz-animation-name", 324 | "-ms-animation-name", 325 | "-o-animation-name", 326 | "animation-name", 327 | "-webkit-animation-duration", 328 | "-moz-animation-duration", 329 | "-ms-animation-duration", 330 | "-o-animation-duration", 331 | "animation-duration", 332 | "-webkit-animation-play-state", 333 | "-moz-animation-play-state", 334 | "-ms-animation-play-state", 335 | "-o-animation-play-state", 336 | "animation-play-state", 337 | "-webkit-animation-timing-function", 338 | "-moz-animation-timing-function", 339 | "-ms-animation-timing-function", 340 | "-o-animation-timing-function", 341 | "animation-timing-function", 342 | "-webkit-animation-delay", 343 | "-moz-animation-delay", 344 | "-ms-animation-delay", 345 | "-o-animation-delay", 346 | "animation-delay", 347 | "-webkit-animation-iteration-count", 348 | "-moz-animation-iteration-count", 349 | "-ms-animation-iteration-count", 350 | "-o-animation-iteration-count", 351 | "animation-iteration-count", 352 | "-webkit-animation-direction", 353 | "-moz-animation-direction", 354 | "-ms-animation-direction", 355 | "-o-animation-direction", 356 | "animation-direction" 357 | ], 358 | [ 359 | "quotes", 360 | "counter-reset", 361 | "counter-increment", 362 | "resize", 363 | "-webkit-user-select", 364 | "-moz-user-select", 365 | "-ms-user-select", 366 | "user-select", 367 | "nav-index", 368 | "nav-up", 369 | "nav-right", 370 | "nav-down", 371 | "nav-left", 372 | "pointer-events", 373 | "will-change", 374 | "clip", 375 | "clip-path", 376 | "zoom" 377 | ] 378 | ] 379 | } 380 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Универсальные настройки редактора 2 | # 3 | # https://habrahabr.ru/post/220131/ 4 | # Скачать плагин: http://editorconfig.org/#download 5 | # Sublime Text: https://packagecontrol.io/packages/EditorConfig 6 | # Atom: https://github.com/sindresorhus/atom-editorconfig 7 | 8 | root = true 9 | 10 | [*] 11 | charset = utf-8 12 | indent_style = space 13 | indent_size = 2 14 | end_of_line = lf 15 | trim_trailing_whitespace = true 16 | insert_final_newline = true 17 | 18 | [*.{rb,php}] 19 | indent_size = 4 20 | 21 | [*.md] 22 | trim_trailing_whitespace = false 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Saved/ 2 | _arc/ 3 | bower_components/ 4 | node_modules/ 5 | .vscode/ 6 | .DS_Store 7 | *.log 8 | *.sublime-* 9 | *.rar 10 | *.zip 11 | .idea 12 | .publish 13 | ex_files 14 | Thumbs.db 15 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | loglevel=silent 2 | -------------------------------------------------------------------------------- /.yaspellerrc: -------------------------------------------------------------------------------- 1 | { 2 | "excludeFiles": [ 3 | ".git", 4 | "node_modules" 5 | ], 6 | "lang": "ru", 7 | "fileExtensions": [ 8 | ".md", 9 | ".html", 10 | ".css" 11 | ], 12 | "dictionary": [ 13 | "Кодгайд", 14 | "вендорными", 15 | "вендорный", 16 | "вендорные", 17 | "слэш", 18 | "ричные", 19 | "коммит", 20 | "коммитом", 21 | "коммита", 22 | "коммиту", 23 | "транслит" 24 | ], 25 | "ignoreTags": ["script"], 26 | "ignoreUrls": true, 27 | "findRepeatWords": false 28 | } 29 | -------------------------------------------------------------------------------- /abbreviations.md: -------------------------------------------------------------------------------- 1 | # Словарь допустимых сокращений в именах классов 2 | 3 | Слово | Сокращения 4 | ------------ | ------------- 5 | `button` | `btn` 6 | `dropdown` | `drop` 7 | `wrapper` | `wrap` 8 | `background` | `bg` 9 | `column` | `col` 10 | `image` | `img` 11 | `picture` | `pict` 12 | `extra-small` | `xs` 13 | `small` | `sm` 14 | `medium` | `md` 15 | `large` | `lg` 16 | `extra-large` | `xl` 17 | 18 | Дополнительно: 19 | 20 | - [Слова, часто используемые в CSS-классах](https://github.com/yoksel/common-words) 21 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 |Стандарты для разработки гибкого, надежного и поддерживаемого кода на HTML и CSS.
19 |Соблюдайте предложенные здесь соглашения. Если вы нашли ошибку, сообщите об этом. Если у вас есть что дополнить или вы хотите принять участие в разработке этих соглашений, пожалуйста, создайте issue на GitHub.
85 |88 |90 |Вне зависимости от количества разработчиков, код в любом проекте должен быть написан так, словно его писал один человек.
89 |
a
, span
, small
, strong
, em
, i
, kbd
, code
) допустимо не переносить на новые строки./
) в конец одиночного тега.</li>
или </body>
).113 |122 |<nav class="main-nav">
114 |<ul>
115 |<li><a href="/index.html">Главная</a></li>
116 |<li><a href="/contacts.html">Контакты</a></li>
117 |</ul>
118 |</nav>
119 |<br>
120 |<img src="logo.svg" width="50" height="50" alt="Company">
121 |
<!DOCTYPE html>
lang
для <html>
<head>
указывайте кодировку (обычно UTF-8
)136 |148 |<!DOCTYPE html>
137 |<html lang="ru">
138 |<head>
139 |<meta charset="UTF-8">
140 |<title>Заголовок страницы</title>
141 |</head>
142 |<body>
143 |<img src="logo.svg" width="50" height="50" alt="Company">
144 |<h1>Привет, мир!</h1>
145 |</body>
146 |</html>
147 |
При подключении CSS и JavaScript файлов не указывайте атрибут type
(text/css
для стилей и text/javascript
для скриптов являются значениями по умолчанию).
CSS-файлы подключайте в <head>
, JavaScript-файлы — перед </body>
159 |165 |<!-- Внешний CSS -->
160 |<link rel="stylesheet" href="style.css">
161 |162 |
<!-- Внешний JavaScript -->
163 |<script src="script.js"></script>
164 |
Очередность атрибутов должна быть единообразной.
172 |Указывайте атрибуты data-*
, aria-*
, role
и логические атрибуты последними.
176 |182 |<a class="btn" href="#modal-call-me" data-modal="toggle">Перезвоните</a>
177 |178 |
<input type="text" class="field-text" disabled>
179 |180 |
<img src="logo.svg" width="50" height="50" alt="Company">
181 |
<img>
должны быть указаны размеры (без единиц измерения, то есть, в пикселях).197 |210 |<header class="page-header">
198 |<a href="/" class="logo">
199 |<img src="logo.svg" width="50" height="50" alt="Company">
200 |</a>
201 |...
202 |<a href="/login" class="login">Войти</a>
203 |<!-- <a href="/logout" class="login">Выйти</a> -->
204 |</header>
205 |206 |
<section class="catalog">
207 |...
208 |</section>
209 |
.foo > .bar
).:
для каждого объявления. Не ставьте пробел перед двоеточием.box-shadow
).rgb()
, rgba()
, hsl()
, hsla()
, или rect()
.0.5
вместо .5
).#fff
вместо #FFF
).#fff
вместо #ffffff
).input[type="text"]
).margin: 0;
вместо margin: 0px;
).245 |263 |/* Хороший CSS */
246 |.selector > .some,
247 |.selector-secondary {
248 |padding: 15px;
249 |margin-bottom: 15px;
250 |line-height: 1;
251 |background-color: rgba(0,0,0,0.5);
252 |box-shadow: 0 1px 2px #ccc, inset 0 1px 0 #fff;
253 |}
254 |255 |
/* Плохой CSS */
256 |.selector>.some ,.selector-secondary{
257 |padding:15px;
258 |margin:0 0px 15px;
259 |line-height :1em;
260 |background-color: rgba(0, 0, 0, .5);
261 |box-shadow:0 1px 2px #ccc,inset 0 1px 0 #FFF;}
262 |
-
в местах разделения слов (не используйте как разделитель слов один символ нижнего подчеркивания, не используйте camelCase)..js-*
для работы с JavaScript. Такие классы должны отсутствовать в CSS.Используйте БЭМ-именование, если знакомы с этой методологией.
281 |284 |299 |/* Хорошие селекторы */
285 |.page-header { ... }
286 |.comment { ... }
287 |.sidebar { ... }
288 |.gallery { ... }
289 |.gallery__item { ... }
290 |291 |
/* Плохие селекторы */
292 |.t { ... }
293 |.root span a { ... }
294 |.red { ... }
295 |.my_block { ... }
296 |.HeaderOfMyBlock { ... }
297 |.eto-moy-perviy-klass { ... }
298 |
Объявления логически связанных свойств должны быть сгруппированы в следующем порядке:
306 |Позиционирование может удалить элемент из нормального потока документа и переопределить блочную модель связанных стилей, поэтому указывайте его первым. Блочная модель диктует размеры и расположение компонента, пишите ее второй.
315 |В примере кода группы правил разделены пустыми строками. Делать такие разделители не обязательно.
316 |319 |344 |.selector {
320 |position: absolute;
321 |top: 0;
322 |right: 0;
323 |bottom: 0;
324 |left: 0;
325 |z-index: 100;
326 |327 |
display: block;
328 |float: right;
329 |width: 100px;
330 |height: 100px;
331 |332 |
font: 13px/1.5 "Helvetica Neue", sans-serif;
333 |color: #333;
334 |text-align: center;
335 |336 |
background-color: #f5f5f5;
337 |border: 1px solid #e5e5e5;
338 |border-radius: 3px;
339 |opacity: 1;
340 |341 |
transition: all 0.3s;
342 |}
343 |
Оставляте пустую строку перед селектором или группой селекторов.
351 |Работая с CSS-препроцессорами, оставляйте пустую строку перед любым вложенным селектором и @media
.
355 |369 |/* В CSS-файле: */
356 |.promo {...}
357 |358 |
.gallery {...}
359 |360 |
/* В препроцессорном файле: */
361 |.promo {
362 |display: block;
363 |364 |
&__container {...}
365 |366 |
&__item {...}
367 |}
368 |
Избегайте сокращенных объявлений. К примеру, если нужно задать только нижний внешний отступ, пишите margin-bottom: 10px;
вместо margin: 0 0 10px;
379 |396 |/* Хорошо */
380 |.element {
381 |margin-bottom: 10px;
382 |background-color: red;
383 |background-image: url("image.jpg");
384 |border-top-left-radius: 3px;
385 |border-top-right-radius: 3px;
386 |}
387 |388 |
/* Плохо */
389 |.element {
390 |margin: 0 0 10px;
391 |background: red;
392 |background: url("image.jpg");
393 |border-radius: 3px 3px 0 0;
394 |}
395 |
@import
По сравнению с тегом <link>
правило @import
работает медленнее и может вызвать иные непредвиденные проблемы. Не используйте @import
, используйте альтернативные подходы:
<link>
411 |419 |<!-- Используйте тег link -->
412 |<link rel="stylesheet" href="style.css">
413 |414 |
<!-- Не используйте @imports -->
415 |<style>
416 |@import url("more-styles.css"); /* Плохо! Не надо так! */
417 |</style>
418 |
@media
Помещайте media queries настолько близко к соответствующим наборам правил, насколько это возможно. Не объединяйте их в отдельную таблицу стилей, не помещайте их в конце файла.
426 |Ставьте пробелы вокруг полукруглых скобок.
427 |Ставьте пробел перед указанием значения в условии.
428 |431 |451 |/* В CSS-файле (без препроцессоров): */
432 |.element {
433 |display: block;
434 |}
435 |436 |
@media (min-width: 480px) {
437 |.element {
438 |display: none;
439 |}
440 |}
441 |442 |
/* В препроцессорном файле: */
443 |.element {
444 |display: block;
445 |446 |
@media (min-width: $screen-sm) {
447 |display: none;
448 |}
449 |}
450 |
Оставляйте отступы для каждого свойства так, чтобы значения выстраивались в вертикальную линию.
458 |Не пишите свойства с вендорными префиксами вручную. Используете Autoprefixer в рамках автоматизации или его он-лайн сервис.
459 |462 |467 |.selector {
463 |-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.15);
464 |box-shadow: 0 1px 2px rgba(0,0,0,0.15);
465 |}
466 |