diff --git a/Readme.md b/Readme.md index 8d23780..947d906 100644 --- a/Readme.md +++ b/Readme.md @@ -1,21 +1,21 @@ -# Стиль кода Академии HTML -Стиль кода можно [посмотреть тут](https://codeguide.academy/). +# Стиль кода .html academy + +Это исходники, публичная версия на сайте [codeguide.academy](https://codeguide.academy/). ## Благодарности * [Code Guide](http://codeguide.co) by @mdo * [CSS Guidelines](http://cssguidelin.es) by Harry Roberts * [Idiomatic CSS](https://github.com/necolas/idiomatic-css) by Nicolas Gallagher -* [Primer Guidelines](https://styleguide.github.com/primer/principles/) by GitHub +* [Primer Guidelines](https://primer.style/css/) by GitHub ## Лицензия -Лицензия MIT, смотрите файл `License.md`. - -## Конфигурации линтеров - -ESLint — https://github.com/htmlacademy/eslint-config-htmlacademy +[MIT](./License.md). -Stylelint — https://github.com/htmlacademy/stylelint-config-htmlacademy +## Правила линтеров -linthtml — https://github.com/htmlacademy/linthtml-config-htmlacademy +* [EditorConfig](.editorconfig) +* [ESLint](https://github.com/htmlacademy/eslint-config-htmlacademy) +* [Stylelint](https://github.com/htmlacademy/stylelint-config-htmlacademy) +* [HTMLHint](https://github.com/htmlacademy/htmlhint-config-htmlacademy) diff --git a/css/normalize.css b/css/normalize.css deleted file mode 100644 index 192eb9c..0000000 --- a/css/normalize.css +++ /dev/null @@ -1,349 +0,0 @@ -/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */ - -/* Document - ========================================================================== */ - -/** - * 1. Correct the line height in all browsers. - * 2. Prevent adjustments of font size after orientation changes in iOS. - */ - -html { - line-height: 1.15; /* 1 */ - -webkit-text-size-adjust: 100%; /* 2 */ -} - -/* Sections - ========================================================================== */ - -/** - * Remove the margin in all browsers. - */ - -body { - margin: 0; -} - -/** - * Render the `main` element consistently in IE. - */ - -main { - display: block; -} - -/** - * Correct the font size and margin on `h1` elements within `section` and - * `article` contexts in Chrome, Firefox, and Safari. - */ - -h1 { - font-size: 2em; - margin: 0.67em 0; -} - -/* Grouping content - ========================================================================== */ - -/** - * 1. Add the correct box sizing in Firefox. - * 2. Show the overflow in Edge and IE. - */ - -hr { - box-sizing: content-box; /* 1 */ - height: 0; /* 1 */ - overflow: visible; /* 2 */ -} - -/** - * 1. Correct the inheritance and scaling of font size in all browsers. - * 2. Correct the odd `em` font sizing in all browsers. - */ - -pre { - font-family: monospace, monospace; /* 1 */ - font-size: 1em; /* 2 */ -} - -/* Text-level semantics - ========================================================================== */ - -/** - * Remove the gray background on active links in IE 10. - */ - -a { - background-color: transparent; -} - -/** - * 1. Remove the bottom border in Chrome 57- - * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. - */ - -abbr[title] { - border-bottom: none; /* 1 */ - text-decoration: underline; /* 2 */ - text-decoration: underline dotted; /* 2 */ -} - -/** - * Add the correct font weight in Chrome, Edge, and Safari. - */ - -b, -strong { - font-weight: bolder; -} - -/** - * 1. Correct the inheritance and scaling of font size in all browsers. - * 2. Correct the odd `em` font sizing in all browsers. - */ - -code, -kbd, -samp { - font-family: monospace, monospace; /* 1 */ - font-size: 1em; /* 2 */ -} - -/** - * Add the correct font size in all browsers. - */ - -small { - font-size: 80%; -} - -/** - * Prevent `sub` and `sup` elements from affecting the line height in - * all browsers. - */ - -sub, -sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline; -} - -sub { - bottom: -0.25em; -} - -sup { - top: -0.5em; -} - -/* Embedded content - ========================================================================== */ - -/** - * Remove the border on images inside links in IE 10. - */ - -img { - border-style: none; -} - -/* Forms - ========================================================================== */ - -/** - * 1. Change the font styles in all browsers. - * 2. Remove the margin in Firefox and Safari. - */ - -button, -input, -optgroup, -select, -textarea { - font-family: inherit; /* 1 */ - font-size: 100%; /* 1 */ - line-height: 1.15; /* 1 */ - margin: 0; /* 2 */ -} - -/** - * Show the overflow in IE. - * 1. Show the overflow in Edge. - */ - -button, -input { /* 1 */ - overflow: visible; -} - -/** - * Remove the inheritance of text transform in Edge, Firefox, and IE. - * 1. Remove the inheritance of text transform in Firefox. - */ - -button, -select { /* 1 */ - text-transform: none; -} - -/** - * Correct the inability to style clickable types in iOS and Safari. - */ - -button, -[type="button"], -[type="reset"], -[type="submit"] { - -webkit-appearance: button; -} - -/** - * Remove the inner border and padding in Firefox. - */ - -button::-moz-focus-inner, -[type="button"]::-moz-focus-inner, -[type="reset"]::-moz-focus-inner, -[type="submit"]::-moz-focus-inner { - border-style: none; - padding: 0; -} - -/** - * Restore the focus styles unset by the previous rule. - */ - -button:-moz-focusring, -[type="button"]:-moz-focusring, -[type="reset"]:-moz-focusring, -[type="submit"]:-moz-focusring { - outline: 1px dotted ButtonText; -} - -/** - * Correct the padding in Firefox. - */ - -fieldset { - padding: 0.35em 0.75em 0.625em; -} - -/** - * 1. Correct the text wrapping in Edge and IE. - * 2. Correct the color inheritance from `fieldset` elements in IE. - * 3. Remove the padding so developers are not caught out when they zero out - * `fieldset` elements in all browsers. - */ - -legend { - box-sizing: border-box; /* 1 */ - color: inherit; /* 2 */ - display: table; /* 1 */ - max-width: 100%; /* 1 */ - padding: 0; /* 3 */ - white-space: normal; /* 1 */ -} - -/** - * Add the correct vertical alignment in Chrome, Firefox, and Opera. - */ - -progress { - vertical-align: baseline; -} - -/** - * Remove the default vertical scrollbar in IE 10+. - */ - -textarea { - overflow: auto; -} - -/** - * 1. Add the correct box sizing in IE 10. - * 2. Remove the padding in IE 10. - */ - -[type="checkbox"], -[type="radio"] { - box-sizing: border-box; /* 1 */ - padding: 0; /* 2 */ -} - -/** - * Correct the cursor style of increment and decrement buttons in Chrome. - */ - -[type="number"]::-webkit-inner-spin-button, -[type="number"]::-webkit-outer-spin-button { - height: auto; -} - -/** - * 1. Correct the odd appearance in Chrome and Safari. - * 2. Correct the outline style in Safari. - */ - -[type="search"] { - -webkit-appearance: textfield; /* 1 */ - outline-offset: -2px; /* 2 */ -} - -/** - * Remove the inner padding in Chrome and Safari on macOS. - */ - -[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; -} - -/** - * 1. Correct the inability to style clickable types in iOS and Safari. - * 2. Change font properties to `inherit` in Safari. - */ - -::-webkit-file-upload-button { - -webkit-appearance: button; /* 1 */ - font: inherit; /* 2 */ -} - -/* Interactive - ========================================================================== */ - -/* - * Add the correct display in Edge, IE 10+, and Firefox. - */ - -details { - display: block; -} - -/* - * Add the correct display in all browsers. - */ - -summary { - display: list-item; -} - -/* Misc - ========================================================================== */ - -/** - * Add the correct display in IE 10+. - */ - -template { - display: none; -} - -/** - * Add the correct display in IE 10. - */ - -[hidden] { - display: none; -} diff --git a/css/style.css b/css/style.css index acb48a7..a125c80 100644 --- a/css/style.css +++ b/css/style.css @@ -1,3 +1,5 @@ +/* Common */ + *, *::before, *::after { @@ -5,17 +7,20 @@ } html { - font-size: 16px; scroll-behavior: smooth; + height: 100%; } body { margin: 0; - - font: 17px/1.6 "Helvetica", "Arial", sans-serif; + min-height: 100%; + font-size: 16px; + line-height: 1.6; + font-family: "Helvetica", "Arial", sans-serif; color: #5a5a5a; - background-color: #ffffff; + display: flex; + flex-direction: column; } a:link, @@ -34,7 +39,6 @@ h1, h2, h3 { margin: 0; - font-weight: normal; color: #424242; letter-spacing: -0.025em; @@ -60,6 +64,25 @@ h3 { scroll-margin-top: 20px; } +ul li { + margin-bottom: 0.25rem; +} + +.visually-hidden { + position: absolute; + + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + border: 0; + clip: rect(0, 0, 0, 0); + clip-path: inset(100%); +} + +/* Code */ + code, pre { font-family: "Consolas", "Liberation Mono", "Menlo", "Courier", monospace; @@ -67,10 +90,8 @@ pre { code { padding: 2px 4px; - font-size: 95%; color: #d44950; - background-color: #f7f7f9; border-radius: 0.2rem; } @@ -78,29 +99,22 @@ code { pre { display: block; margin: 0 0 1rem; - line-height: 1.4; white-space: pre-wrap; } pre code { padding: 0; - color: inherit; - background-color: transparent; border: 0; } -ul li { - margin-bottom: 0.25rem; -} +/* Header */ header { padding: 1rem 1rem 6rem; - text-align: center; - background-color: #312785; background-image: repeating-linear-gradient(150deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.06) 1px, transparent 0, transparent 41px), repeating-linear-gradient(-150deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.06) 1px, transparent 0, transparent 41px); background-size: 82px 47px; @@ -108,13 +122,11 @@ header { header h1 { margin: 0 0 0.25rem; - color: #ffffff; } header p { margin-top: 0; - font-size: 1.1rem; } @@ -123,33 +135,33 @@ header a:visited { color: #ffffff; } -.visually-hidden { - position: absolute; - - width: 1px; - height: 1px; - margin: -1px; - padding: 0; - overflow: hidden; +.logo { + width: 300px; + height: 300px; +} - border: 0; +.logo-list-js { + margin: 11px 23px 0; +} - clip: rect(0, 0, 0, 0); - clip-path: inset(100%); +@media (min-width: 38em) { + header { + padding-bottom: 4rem; + } } +/* Logo list */ + .logo-list { - max-width: 550px; margin: 50px auto; } .logo-list ul { display: flex; flex-wrap: wrap; - justify-content: space-around; + justify-content: center; margin: 0; padding: 0; - list-style: none; } @@ -158,20 +170,18 @@ header a:visited { margin-left: 10px; } -.logo { - width: 300px; - height: 300px; -} +/* Gudie content */ .guide-content { display: flex; flex-wrap: wrap; } +/* Sidebar */ + .sidebar { display: flex; flex-direction: column; - width: 100%; } @@ -201,6 +211,84 @@ header a:visited { padding-left: 1rem; } +@media (min-width: 48em) { + .sidebar { + flex-direction: row; + flex-wrap: wrap; + padding: 2rem 0; + } + + .sidebar-col { + width: 50%; + padding: 1rem 3rem; + } + + .sidebar-col + .sidebar-col { + border-top: 0; + } +} + +@media (min-width: 75em) { + .sidebar { + position: sticky; + top: 0; + bottom: 0; + flex-direction: column; + flex-wrap: nowrap; + align-self: flex-start; + width: 230px; + height: 100vh; + padding: 0 1rem; + overflow-y: auto; + line-height: 1.25; + border-right: 1px solid #e5e5e5; + } + + .sidebar-col { + flex-shrink: 0; + width: 100%; + padding: 0; + } + + .sidebar-col-first { + padding-top: 1.75rem; + } + + .sidebar-col-last { + padding-bottom: 1.75rem; + } + + .sidebar-col + .sidebar-col { + margin-top: 1.75em; + } + + .sidebar-col > a { + display: block; + + font-size: 0.8rem; + font-weight: bold; + } + + .sidebar-menu { + padding: 0; + margin: 0.5em 0 0; + list-style: none; + font-size: 0.7rem; + } + + .sidebar-menu li { + margin: 0; + line-height: 1.45; + } + + .sidebar-menu a { + display: block; + padding: 0.25em 0; + } +} + +/* Chapter */ + .chapters { width: 100%; } @@ -222,7 +310,6 @@ header a:visited { .chapter-part { display: flex; flex-direction: column; - border-bottom: 1px solid #e5e5e5; } @@ -246,9 +333,51 @@ header a:visited { background-color: #fafafa; } +@media (min-width: 38em) { + .chapter h2 { + padding: 2rem 2rem 2.5rem; + } + + .chapter-part-col { + padding: 2rem; + } +} + + +@media (min-width: 48em) { + .chapter h2 { + padding: 2rem 3rem 2.5rem; + } + + .chapter-part { + flex-direction: row; + } + + .chapter-part-col { + width: 50%; + padding: 3rem 1.5rem; + } + + .chapter-part-col--full-width { + width: 100%; + } + + .chapter-part-col + .chapter-part-col { + border-top: 0; + } +} + +@media (min-width: 75em) { + .chapters { + width: calc(100% - 230px); + } +} + +/* Footer */ + footer { padding: 2rem; - + margin-top: auto; background-color: #2d2d44; } @@ -279,7 +408,6 @@ footer { .icon { min-width: 2rem; min-height: 2rem; - background-repeat: no-repeat; background-position: center; background-size: calc(100% - 5px); @@ -291,156 +419,29 @@ footer { } .icon-vk { - background-image: url("http://github.com/img/icon-vkontakte.svg"); + background-image: url("http://github.com/img/icon-vkontakte.svg"); } .icon-fb { - background-image: url("http://github.com/img/icon-facebook.svg"); + background-image: url("http://github.com/img/icon-facebook.svg"); } .icon-tw { - background-image: url("http://github.com/img/icon-twitter.svg"); + background-image: url("http://github.com/img/icon-twitter.svg"); } .icon-ig { - background-image: url("http://github.com/img/icon-instagram.svg"); + background-image: url("http://github.com/img/icon-instagram.svg"); } .github-link { display: inline-block; width: 91px; height: 16px; - - background-image: url("http://github.com/img/github.svg"); + background-image: url("http://github.com/img/github.svg"); } -@media (min-width: 38em) { - header { - padding-bottom: 4rem; - } - - html { - font-size: 20px; - } - - .chapter h2 { - padding: 2rem 2rem 2.5rem; - } - - .chapter-part-col { - padding: 2rem; - } -} - -@media (min-width: 48em) { - .sidebar { - flex-direction: row; - flex-wrap: wrap; - - padding: 2rem 0; - } - - .sidebar-col { - width: 50%; - padding: 1rem 3rem; - } - - .sidebar-col + .sidebar-col { - border-top: 0; - } - - .chapter h2 { - padding: 2rem 3rem 2.5rem; - } - - .chapter-part { - flex-direction: row; - } - - .chapter-part-col { - width: 50%; - padding: 3rem 1.5rem; - } - - .chapter-part-col--full-width { - width: 100%; - } - - .chapter-part-col + .chapter-part-col { - border-top: 0; - } -} - -@media (min-width: 75em) { - .chapters { - width: calc(100% - 230px); - } - - .sidebar { - position: sticky; - top: 0; - bottom: 0; - - flex-direction: column; - flex-wrap: nowrap; - align-self: flex-start; - - width: 230px; - height: 100vh; - padding: 0 1rem; - - overflow-y: auto; - line-height: 1.25; - border-right: 1px solid #e5e5e5; - } - - .sidebar-col { - flex-shrink: 0; - - width: 100%; - padding: 0; - } - - .sidebar-col-first { - padding-top: 1.75rem; - } - - .sidebar-col-last { - padding-bottom: 1.75rem; - } - - .sidebar-col + .sidebar-col { - margin-top: 1.75em; - } - - .sidebar-col > a { - display: block; - - font-size: 0.8rem; - font-weight: bold; - } - - .sidebar-menu { - padding: 0; - margin: 0.5em 0 0; - - list-style: none; - - font-size: 0.7rem; - } - - .sidebar-menu li { - margin: 0; - - line-height: 1.45; - } - - .sidebar-menu a { - display: block; - - padding: 0.25em 0; - } -} +/* Prism */ /* override default prism theme */ code[class*="language-"], diff --git a/html-css.html b/html-css.html index 611d0cd..8e52a6a 100644 --- a/html-css.html +++ b/html-css.html @@ -2,17 +2,16 @@
-github.com/htmlacademy/codeguide
@@ -213,7 +212,7 @@<html>
с языком документа lang
<head>
<title>
<meta charset="utf-8">
. Кодировка символов на странице явно указана, чтобы обеспечить корректное отображение текста. Кодировка utf-8
предпочтительна.<meta charset="utf-8">
. Кодировка символов на странице явно указана, чтобы обеспечить корректное отображение текста.<body>
iframe
указаны размеры.- Документ проходит проверку на валидность. Для проверки используется современный валидатор. + Документ проходит проверку на валидность. Для проверки используется современный валидатор.
/* Хорошо */
.field[type="text"] {
- background-color: url("http://github.com/images/cat.jpg");
+ background-image: url("http://github.com/images/cat.jpg");
}
/* Плохо */
.field[type=text] {
- background-color: url(http://github.com/images/cat.jpg);
+ background-image: url(http://github.com/images/cat.jpg);
}
@@ -816,11 +823,6 @@ Единицы измерения не указаны там, где в них нет необходимости.
+/* Хорошо */
+:root {
+ --size: 0px;
+}
+
.element {
border: 0;
box-shadow: 0 1px 2px #cccccc, inset 0 1px 0 #ffffff;
margin-top: 0;
+ width: calc(100% - var(--size));
}
/* Плохо */
+:root {
+ --size: 0;
+}
+
.element {
border: 0px;
box-shadow: 0px 1px 2px #cccccc, inset 0px 1px 0 #ffffff;
margin-top: 0px;
+ width: calc(100% - var(--size));
}
@@ -1065,21 +1079,21 @@ github.com/htmlacademy/codeguide
@@ -41,12 +40,16 @@github.com/htmlacademy/codeguide
@@ -97,7 +96,7 @@Для правильного форматирования используйте файл .editorconfig в вашем редакторе.+
Для правильного форматирования используйте файл .editorconfig в вашем редакторе.
Для отступов используются два пробела. Знак табуляции не используется
@@ -248,7 +247,7 @@Запрещено использовать имена переменных, которые используются во внешних областях видимости
-Запрещено называть переменные и свойства ключевыми словами JS
+Запрещено называть переменные и свойства ключевыми словами JS
Запрещено использовать переменные, не объявленные ранее. При использовании переменной, объявленной в другом модуле в глобальной области видимости, нужно обращаться к ней как к свойству объекта window
В условиях не используется небезопасное отрицание, например использование !
в in
или instanceof
без скобок
Запрещено сравнение с NaN
. Для проверки, является ли результат операции числовым, нужно использовать Number.isNaN
Запрещено сравнение с NaN
. Для проверки, является ли результат операции числовым, нужно использовать Number.isNaN
Запрещено использовать case
без break
или return
в блоках switch