├── _layouts ├── post.html └── default.html ├── _includes ├── html │ ├── encoding.html │ ├── doctype.html │ ├── naming.html │ ├── reducing-markup.html │ ├── boolean-attributes.html │ ├── attribute-order.html │ ├── style-script.html │ └── syntax.html ├── css │ ├── prefixed-properties.css │ ├── class-names.css │ ├── nesting.scss │ ├── organization-files.txt │ ├── comments.css │ ├── media-queries.css │ ├── selectors.css │ ├── shorthand.css │ ├── organization-comments.css │ ├── syntax.css │ ├── single-declarations.css │ └── declaration-order.css ├── tweet-button.html ├── header.html ├── js.html ├── footer.html └── syntax.css ├── font ├── fontello.eot ├── fontello.ttf ├── fontello.woff └── fontello.svg ├── pt-br.html ├── _config.yml ├── README-original.md ├── .gitignore ├── README.md ├── code-guide.css ├── index.html └── en.html /_layouts/post.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | --- 4 | 5 | {{ content }} 6 | -------------------------------------------------------------------------------- /_includes/html/encoding.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /font/fontello.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diegoeis/code-guide/HEAD/font/fontello.eot -------------------------------------------------------------------------------- /font/fontello.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diegoeis/code-guide/HEAD/font/fontello.ttf -------------------------------------------------------------------------------- /font/fontello.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diegoeis/code-guide/HEAD/font/fontello.woff -------------------------------------------------------------------------------- /_includes/html/doctype.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /_includes/html/naming.html: -------------------------------------------------------------------------------- 1 | .element { 2 | ... 3 | } 4 | .element-title { 5 | ... 6 | } 7 | .element-button { 8 | ... 9 | } 10 | -------------------------------------------------------------------------------- /_includes/html/reducing-markup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /_includes/css/prefixed-properties.css: -------------------------------------------------------------------------------- 1 | /* Prefixed properties */ 2 | .selector { 3 | -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15); 4 | box-shadow: 0 1px 2px rgba(0,0,0,.15); 5 | } 6 | -------------------------------------------------------------------------------- /_includes/html/boolean-attributes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /_includes/html/attribute-order.html: -------------------------------------------------------------------------------- 1 | 2 | Example link 3 | 4 | 5 | 6 | 7 | ... 8 | -------------------------------------------------------------------------------- /_includes/css/class-names.css: -------------------------------------------------------------------------------- 1 | /* Bad example */ 2 | .t { ... } 3 | .red { ... } 4 | .header { ... } 5 | 6 | /* Good example */ 7 | .tweet { ... } 8 | .important { ... } 9 | .tweet-header { ... } 10 | -------------------------------------------------------------------------------- /_includes/css/nesting.scss: -------------------------------------------------------------------------------- 1 | // Without nesting 2 | .table > thead > tr > th { … } 3 | .table > thead > tr > td { … } 4 | 5 | // With nesting 6 | .table > thead > tr { 7 | > th { … } 8 | > td { … } 9 | } 10 | -------------------------------------------------------------------------------- /_includes/css/organization-files.txt: -------------------------------------------------------------------------------- 1 | stylesheets/ 2 | ├── normalize.css 3 | ├── buttons.css 4 | ├── forms.css 5 | ├── grid.css 6 | ├── header.css 7 | ├── footer.css 8 | ├── pagination.css 9 | └── input-group.css 10 | -------------------------------------------------------------------------------- /_includes/css/comments.css: -------------------------------------------------------------------------------- 1 | /* Bad example */ 2 | /* Modal header */ 3 | .modal-header { 4 | ... 5 | } 6 | 7 | /* Good example */ 8 | /* Wrapping element for .modal-title and .modal-close */ 9 | .modal-header { 10 | ... 11 | } 12 | -------------------------------------------------------------------------------- /_includes/css/media-queries.css: -------------------------------------------------------------------------------- 1 | .element { ... } 2 | .element-avatar { ... } 3 | .element-selected { ... } 4 | 5 | @media (min-width: 480px) { 6 | .element { ...} 7 | .element-avatar { ... } 8 | .element-selected { ... } 9 | } 10 | -------------------------------------------------------------------------------- /_includes/tweet-button.html: -------------------------------------------------------------------------------- 1 |
2 | Tweet 3 |
4 | -------------------------------------------------------------------------------- /_includes/html/style-script.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /_includes/html/syntax.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Page title 5 | 6 | 7 | Company 8 |

Hello, world!

9 | 10 | 11 | -------------------------------------------------------------------------------- /_includes/css/selectors.css: -------------------------------------------------------------------------------- 1 | /* Bad example */ 2 | span { ... } 3 | .page-container #stream .stream-item .tweet .tweet-header .username { ... } 4 | .avatar { ... } 5 | 6 | /* Good example */ 7 | .avatar { ... } 8 | .tweet-header .username { ... } 9 | .tweet .avatar { ... } 10 | -------------------------------------------------------------------------------- /pt-br.html: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /_includes/css/shorthand.css: -------------------------------------------------------------------------------- 1 | /* Bad example */ 2 | .element { 3 | margin: 0 0 10px; 4 | background: red; 5 | background: url("image.jpg"); 6 | border-radius: 3px 3px 0 0; 7 | } 8 | 9 | /* Good example */ 10 | .element { 11 | margin-bottom: 10px; 12 | background-color: red; 13 | background-image: url("image.jpg"); 14 | border-top-left-radius: 3px; 15 | border-top-right-radius: 3px; 16 | } 17 | -------------------------------------------------------------------------------- /_includes/css/organization-comments.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Component section heading 3 | */ 4 | 5 | .element { ... } 6 | 7 | 8 | /* 9 | * Component section heading 10 | * 11 | * Sometimes you need to include optional context for the entire component. Do that up here if it's important enough. 12 | */ 13 | 14 | .element { ... } 15 | 16 | /* Contextual sub-component or modifer */ 17 | .element-heading { ... } 18 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | name: Code Guide by @mdo 2 | description: Standards for developing flexible, durable, and sustainable HTML and CSS. 3 | url: http://mdo.github.com/code-guide 4 | name_ptbr: Guia de Código do @mdo 5 | description_ptbr: Padrões para desenvolver código HTML e CSS flexíveis, duráveis e sustentáveis. 6 | url_ptbr: http://diegoeis.github.com/code-guide/pt-br 7 | 8 | markdown: rdiscount 9 | permalink: pretty 10 | pygments: true 11 | -------------------------------------------------------------------------------- /_includes/css/syntax.css: -------------------------------------------------------------------------------- 1 | /* Bad CSS */ 2 | .selector, .selector-secondary, .selector[type=text] { 3 | padding:15px; 4 | margin:0px 0px 15px; 5 | background-color:rgba(0, 0, 0, 0.5); 6 | box-shadow:0 1px 2px #CCC,inset 0 1px 0 #FFFFFF 7 | } 8 | 9 | /* Good CSS */ 10 | .selector, 11 | .selector-secondary, 12 | .selector[type="text"] { 13 | padding: 15px; 14 | margin: 0 0 15px; 15 | background-color: rgba(0,0,0,.5); 16 | box-shadow: 0 1px 2px #ccc, inset 0 1px 0 #fff; 17 | } 18 | -------------------------------------------------------------------------------- /_includes/css/single-declarations.css: -------------------------------------------------------------------------------- 1 | /* Single declarations on one line */ 2 | .span1 { width: 60px; } 3 | .span2 { width: 140px; } 4 | .span3 { width: 220px; } 5 | 6 | /* Multiple declarations, one per line */ 7 | .sprite { 8 | display: inline-block; 9 | width: 16px; 10 | height: 15px; 11 | background-image: url(../img/sprite.png); 12 | } 13 | .icon { background-position: 0 0; } 14 | .icon-home { background-position: 0 -20px; } 15 | .icon-account { background-position: 0 -40px; } 16 | -------------------------------------------------------------------------------- /_includes/header.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |

{{ site.name_ptbr }}

5 |

{{ site.description_ptbr }}

6 | 7 | 15 |
16 |
17 | -------------------------------------------------------------------------------- /_includes/js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /README-original.md: -------------------------------------------------------------------------------- 1 | # Code Guide 2 | 3 | Code Guide is a project for documenting standards for developing flexible, durable, and sustainable HTML and CSS. It comes from years of experience writing code on projects of all sizes. It's not the end-all be-all, but it's a start. 4 | 5 | **[Start reading ☞](http://mdo.github.io/code-guide)** 6 | 7 | ### License 8 | 9 | Released under MIT by, and copyright 2014, @mdo. 10 | 11 | ### Thanks 12 | 13 | Heavily inspired by [Idiomatic CSS](https://github.com/necolas/idiomatic-css) and the [GitHub Styleguide](http://github.com/styleguide). 14 | 15 | <3 16 | -------------------------------------------------------------------------------- /_includes/css/declaration-order.css: -------------------------------------------------------------------------------- 1 | .declaration-order { 2 | /* Positioning */ 3 | position: absolute; 4 | top: 0; 5 | right: 0; 6 | bottom: 0; 7 | left: 0; 8 | z-index: 100; 9 | 10 | /* Box-model */ 11 | display: block; 12 | float: right; 13 | width: 100px; 14 | height: 100px; 15 | 16 | /* Typography */ 17 | font: normal 13px "Helvetica Neue", sans-serif; 18 | line-height: 1.5; 19 | color: #333; 20 | text-align: center; 21 | 22 | /* Visual */ 23 | background-color: #f5f5f5; 24 | border: 1px solid #e5e5e5; 25 | border-radius: 3px; 26 | 27 | /* Misc */ 28 | opacity: 1; 29 | } 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore docs files 2 | _gh_pages 3 | _site 4 | .ruby-version 5 | 6 | # Numerous always-ignore extensions 7 | *.diff 8 | *.err 9 | *.orig 10 | *.log 11 | *.rej 12 | *.swo 13 | *.swp 14 | *.zip 15 | *.vi 16 | *~ 17 | 18 | # OS or Editor folders 19 | .DS_Store 20 | ._* 21 | Thumbs.db 22 | .cache 23 | .project 24 | .settings 25 | .tmproj 26 | *.esproj 27 | nbproject 28 | *.sublime-project 29 | *.sublime-workspace 30 | .idea 31 | 32 | # Komodo 33 | *.komodoproject 34 | .komodotools 35 | 36 | # grunt-html-validation 37 | validation-status.json 38 | validation-report.json 39 | 40 | # Folders to ignore 41 | node_modules 42 | bower_components 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Guia de Código 2 | 3 | Este Guia é um projeto para documentar padrões de desenvolvimento flexíveis, duráveis e sustentáveis de HTML e CSS. Isto vem de anos de experiência escrevendo código em projetos de todos os tamanhos. Isso não é um guia definitivo, mas é um começo. 4 | 5 | **[Comece a ler ☞](http://diegoeis.github.io/code-guide/pt-br)** 6 | 7 | ### Licensa 8 | 9 | Lançado sob MIT, e copyright 2014, [@mdo](http://twitter.com/mdo/). 10 | 11 | ### Obrigado 12 | 13 | Fortemente inspirado por [Idiomatic CSS](https://github.com/necolas/idiomatic-css) e [GitHub Styleguide](http://github.com/styleguide). 14 | 15 | ### Traduções 16 | 17 | [Portuguese](http://diegoeis.github.io/code-guide/) - Translated by [Diego Eis](http://tableless.com.br/) 18 | [Spanish](http://adrianayala.mx/code-guide/es/) - Translated by [Adrian Ayala](http://adrianayala.mx/) 19 | [Indonesian](http://diagramatics.github.io/code-guide-id) - Translated by [Steven Sinatra](http://diagramatics.me) 20 | 21 | <3 22 | -------------------------------------------------------------------------------- /_layouts/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {{ site.name_ptbr }} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | {% include header.html %} 18 | 19 | {{ content }} 20 | 21 | {% include footer.html %} 22 | 23 | {% include js.html %} 24 | 25 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /font/fontello.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copyright (C) 2014 by original authors @ fontello.com 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /_includes/footer.html: -------------------------------------------------------------------------------- 1 | 24 | -------------------------------------------------------------------------------- /_includes/syntax.css: -------------------------------------------------------------------------------- 1 | .hll { background-color: #ffffcc } 2 | /*{ background: #f0f3f3; }*/ 3 | .c { color: #999; } /* Comment */ 4 | .err { color: #AA0000; background-color: #FFAAAA } /* Error */ 5 | .k { color: #006699; } /* Keyword */ 6 | .o { color: #555555 } /* Operator */ 7 | .cm { color: #999; } /* Comment.Multiline */ /* Edited to remove italics and make into comment */ 8 | .cp { color: #009999 } /* Comment.Preproc */ 9 | .c1 { color: #999; } /* Comment.Single */ 10 | .cs { color: #999; } /* Comment.Special */ 11 | .gd { background-color: #FFCCCC; border: 1px solid #CC0000 } /* Generic.Deleted */ 12 | .ge { font-style: italic } /* Generic.Emph */ 13 | .gr { color: #FF0000 } /* Generic.Error */ 14 | .gh { color: #003300; } /* Generic.Heading */ 15 | .gi { background-color: #CCFFCC; border: 1px solid #00CC00 } /* Generic.Inserted */ 16 | .go { color: #AAAAAA } /* Generic.Output */ 17 | .gp { color: #000099; } /* Generic.Prompt */ 18 | .gs { } /* Generic.Strong */ 19 | .gu { color: #003300; } /* Generic.Subheading */ 20 | .gt { color: #99CC66 } /* Generic.Traceback */ 21 | .kc { color: #006699; } /* Keyword.Constant */ 22 | .kd { color: #006699; } /* Keyword.Declaration */ 23 | .kn { color: #006699; } /* Keyword.Namespace */ 24 | .kp { color: #006699 } /* Keyword.Pseudo */ 25 | .kr { color: #006699; } /* Keyword.Reserved */ 26 | .kt { color: #007788; } /* Keyword.Type */ 27 | .m { color: #FF6600 } /* Literal.Number */ 28 | .s { color: #d44950 } /* Literal.String */ 29 | .na { color: #4f9fcf } /* Name.Attribute */ 30 | .nb { color: #336666 } /* Name.Builtin */ 31 | .nc { color: #00AA88; } /* Name.Class */ 32 | .no { color: #336600 } /* Name.Constant */ 33 | .nd { color: #9999FF } /* Name.Decorator */ 34 | .ni { color: #999999; } /* Name.Entity */ 35 | .ne { color: #CC0000; } /* Name.Exception */ 36 | .nf { color: #CC00FF } /* Name.Function */ 37 | .nl { color: #9999FF } /* Name.Label */ 38 | .nn { color: #00CCFF; } /* Name.Namespace */ 39 | .nt { color: #2f6f9f; } /* Name.Tag */ 40 | .nv { color: #003333 } /* Name.Variable */ 41 | .ow { color: #000000; } /* Operator.Word */ 42 | .w { color: #bbbbbb } /* Text.Whitespace */ 43 | .mf { color: #FF6600 } /* Literal.Number.Float */ 44 | .mh { color: #FF6600 } /* Literal.Number.Hex */ 45 | .mi { color: #FF6600 } /* Literal.Number.Integer */ 46 | .mo { color: #FF6600 } /* Literal.Number.Oct */ 47 | .sb { color: #CC3300 } /* Literal.String.Backtick */ 48 | .sc { color: #CC3300 } /* Literal.String.Char */ 49 | .sd { color: #CC3300; font-style: italic } /* Literal.String.Doc */ 50 | .s2 { color: #CC3300 } /* Literal.String.Double */ 51 | .se { color: #CC3300; } /* Literal.String.Escape */ 52 | .sh { color: #CC3300 } /* Literal.String.Heredoc */ 53 | .si { color: #AA0000 } /* Literal.String.Interpol */ 54 | .sx { color: #CC3300 } /* Literal.String.Other */ 55 | .sr { color: #33AAAA } /* Literal.String.Regex */ 56 | .s1 { color: #CC3300 } /* Literal.String.Single */ 57 | .ss { color: #FFCC33 } /* Literal.String.Symbol */ 58 | .bp { color: #336666 } /* Name.Builtin.Pseudo */ 59 | .vc { color: #003333 } /* Name.Variable.Class */ 60 | .vg { color: #003333 } /* Name.Variable.Global */ 61 | .vi { color: #003333 } /* Name.Variable.Instance */ 62 | .il { color: #FF6600 } /* Literal.Number.Integer.Long */ 63 | 64 | .css .o, 65 | .css .o + .nt, 66 | .css .nt + .nt { color: #999; } 67 | -------------------------------------------------------------------------------- /code-guide.css: -------------------------------------------------------------------------------- 1 | --- 2 | layout: nil 3 | --- 4 | 5 | 6 | /* 7 | * Fonts 8 | */ 9 | 10 | @font-face { 11 | font-family: 'fontello'; 12 | src: url('font/fontello.eot'); 13 | src: url('font/fontello.eot#iefix') format('embedded-opentype'), 14 | url('font/fontello.woff') format('woff'), 15 | url('font/fontello.ttf') format('truetype'), 16 | url('font/fontello.svg') format('svg'); 17 | font-weight: normal; 18 | font-style: normal; 19 | } 20 | 21 | [class^="icon-"]:before, [class*=" icon-"]:before { 22 | font-family: "fontello"; 23 | font-style: normal; 24 | font-weight: normal; 25 | speak: none; 26 | display: inline-block; 27 | text-decoration: inherit; 28 | width: 1em; 29 | margin-right: .2em; 30 | text-align: center; 31 | font-variant: normal; 32 | text-transform: none; 33 | } 34 | 35 | .icon-github-circled:before { content: '\e800'; } /* '' */ 36 | .icon-twitter:before { content: '\e801'; } /* '' */ 37 | 38 | 39 | /* 40 | * Scaffolding and type 41 | */ 42 | 43 | html { 44 | font-size: 16px; 45 | } 46 | @media (min-width: 48rem) { 47 | html { 48 | font-size: 20px; 49 | } 50 | } 51 | 52 | body { 53 | margin: 0; 54 | font: 1rem/1.5 "PT Sans", sans-serif; 55 | color: #5a5a5a; 56 | } 57 | 58 | a { 59 | color: #08c; 60 | text-decoration: none; 61 | } 62 | a:hover { 63 | text-decoration: underline; 64 | } 65 | 66 | h1, h2, h3, h4 { 67 | margin: 0 0 .5rem; 68 | font-weight: normal; 69 | line-height: 1; 70 | color: #2a2a2a; 71 | letter-spacing: -.05em; 72 | } 73 | h1 { font-size: 3rem; } 74 | h2 { font-size: 2.5rem; } 75 | h3 { font-size: 1.75rem; } 76 | h4 { font-size: 1.25rem } 77 | 78 | p { 79 | margin: 0 0 1rem; 80 | } 81 | .lead { 82 | font-size: 1.3rem; 83 | } 84 | 85 | blockquote { 86 | position: relative; 87 | margin: 0 1rem 1rem; 88 | font-style: italic; 89 | color: #7a7a7a; 90 | } 91 | blockquote p { 92 | margin-bottom: 0; 93 | } 94 | 95 | ul li { 96 | margin-bottom: .25rem; 97 | } 98 | 99 | /* Tighten up margin on last items */ 100 | p:last-child, 101 | ul:last-child, 102 | blockquote:last-child{ 103 | margin-bottom: 0; 104 | } 105 | 106 | 107 | 108 | /* 109 | * Code 110 | */ 111 | 112 | code, 113 | pre { 114 | font-family: "PT Mono", Menlo, "Courier New", monospace; 115 | font-size: 95%; 116 | } 117 | code { 118 | padding: 2px 4px; 119 | font-size: 85%; 120 | color: #d44950; 121 | background-color: #f7f7f9; 122 | border-radius: .2rem; 123 | } 124 | 125 | pre { 126 | display: block; 127 | margin: 0 0 1rem; 128 | line-height: 1.4; 129 | white-space: pre; 130 | white-space: pre-wrap; 131 | } 132 | pre code { 133 | padding: 0; 134 | color: inherit; 135 | background-color: transparent; 136 | border: 0; 137 | } 138 | .highlight { 139 | margin: 0; 140 | } 141 | .highlight pre { 142 | margin-bottom: 0; 143 | } 144 | .highlight + .highlight { 145 | margin-top: 1rem; 146 | } 147 | 148 | 149 | /* 150 | * The Grid 151 | */ 152 | 153 | .col { 154 | padding: 2rem 1rem; 155 | } 156 | .col p { 157 | max-width: 40rem; 158 | } 159 | .col + .col { 160 | border-top: 1px solid #dfe1e8; 161 | background-color: #f7f7f9; 162 | } 163 | @media (min-width: 38rem) { 164 | .col { 165 | padding: 2rem; 166 | } 167 | } 168 | @media (min-width: 48rem) { 169 | .section { 170 | display: table; 171 | width: 100%; 172 | table-layout: fixed; 173 | } 174 | .col { 175 | display: table-cell; 176 | padding: 3rem; 177 | vertical-align: top; 178 | } 179 | .col + .col { 180 | border-top: 0; 181 | } 182 | } 183 | 184 | 185 | /* 186 | * Masthead 187 | */ 188 | 189 | .masthead { 190 | padding: 3rem 1rem; 191 | color: rgba(255,255,255,.5); 192 | text-align: center; 193 | background-color: #2a3440; 194 | } 195 | .masthead h1 { 196 | color: #fff; 197 | margin-bottom: .25rem; 198 | } 199 | .masthead .icon { 200 | display: inline-block; 201 | font-size: 3rem; 202 | margin: 0 .5rem; 203 | } 204 | .masthead-links { 205 | font-size: 2rem; 206 | } 207 | .masthead-links a { 208 | color: rgba(255,255,255,.5); 209 | text-decoration: none; 210 | transition: all .15s linear; 211 | } 212 | .masthead-links a:hover { 213 | color: #fff; 214 | } 215 | 216 | @media (min-width: 38rem) { 217 | .masthead { 218 | padding-top: 4rem; 219 | padding-bottom: 4rem; 220 | } 221 | } 222 | 223 | 224 | /* 225 | * Sections 226 | */ 227 | 228 | .heading { 229 | padding: 2rem 1rem 1.5rem; 230 | background-color: #dfe1e8; 231 | } 232 | 233 | @media (min-width: 38rem) { 234 | .heading { 235 | padding: 3rem 3rem 2.5rem; 236 | } 237 | } 238 | 239 | .section { 240 | border-bottom: 1px solid #dfe1e8; 241 | } 242 | 243 | 244 | /* 245 | * Footer 246 | */ 247 | 248 | .footer { 249 | padding: 3rem 1rem; 250 | font-size: 90%; 251 | text-align: center; 252 | } 253 | .footer p { 254 | margin-bottom: .5rem; 255 | } 256 | 257 | .quick-links { 258 | list-style: none; 259 | margin-left: 0; 260 | } 261 | .quick-links li { 262 | display: inline; 263 | } 264 | 265 | 266 | /* 267 | * Syntax highlighting 268 | */ 269 | 270 | {% include syntax.css %} 271 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | --- 4 | 5 |
6 |

Índice

7 |
8 |
9 |
10 |

HTML

11 | 22 |
23 |
24 |

CSS

25 | 38 |
39 |
40 | 41 | 42 |
43 |
44 |

Regra de ouro

45 |

Reforce isso, concordando com estas guidelines todas as vezes. Pequenos ou grandes, mostre o que está incorreto. Para adições ou contribuições para este Guia de Código, por favor abra uma Issue no Github.

46 |
47 |
48 |
49 |

Toda linha de código deve parecer que foi escrita por uma única pessoa, não importa a quantidade de contribuidores.

50 |
51 |
52 |
53 | 54 |
55 |

HTML

56 |
57 | 58 |
59 |
60 |

Sintaxe do HTML

61 | 67 |
68 |
69 | {% highlight html %}{% include html/syntax.html %}{% endhighlight %} 70 |
71 |
72 | 73 |
74 |
75 |

Doctype do HTML5

76 |

Reforce os padrões com este simples doctype no início de todas as páginas HTML.

77 |
78 |
79 | {% highlight html %}{% include html/doctype.html %}{% endhighlight %} 80 |
81 |
82 | 83 |
84 |
85 |

Encoding de caractéres

86 |

Assegure-se rapidamente a renderização do seu conteúdo declarando o encoding de caractéres explicitamente.

87 |
88 |
89 | {% highlight html %}{% include html/encoding.html %}{% endhighlight %} 90 |
91 |
92 | 93 |
94 |
95 |

Inserindo CSS e JavaScript

96 |

De acordo com as especificações do HTML5, não há necessidade de especificar um atributo type quando incluímos arquivos de CSS e JavaScript como text/css e text/javascript.

97 |

Links para especificação do HTML5

98 | 103 |
104 |
105 | {% highlight html %}{% include html/style-script.html %}{% endhighlight %} 106 |
107 |
108 | 109 |
110 |
111 |

Praticidade em vez de pureza

112 |

Esforce-se para manter o padrão e a semântica do HTML, mas não às custas da praticidade. Use o mínimo de código com a menor complexidade possível.

113 |
114 |
115 | 116 |
117 |
118 |

Ordem dos atributos

119 |

Atributos HTML devem usar esta ordem em particular para facilitar a leitura do código.

120 | 129 |
130 |
131 | {% highlight html %}{% include html/attribute-order.html %}{% endhighlight %} 132 |
133 |
134 | 135 |
136 |
137 |

Atributos booleanos

138 |

Um atributo boleano é o único que não precisa ter valores declarados. O XHTML precisa que você declare um valor, mas no HTML5 isso não é necessário.

139 |

Para uma leitura adicional, consulte a seção do WhatWG sobre atributos booleanos:

140 |
141 |

A presença de um atributo boleano representa um valor verdadeiro e a ausência do atributo representa um valor falso.

142 |
143 |

Se você precisa incluir valores nos atributos, você não precisa seguir esta regra do WhatWG:

144 |
145 |

Se o atributo está presente, seu valor deve ser uma string vazia ou [...] o nome canônico do atributo, sem espaços em branco.

146 |
147 |

Resumindo, não adicione nenhum valor.

148 |
149 |
150 | {% highlight html %}{% include html/boolean-attributes.html %}{% endhighlight %} 151 |
152 |
153 | 154 |
155 |
156 |

Reduzindo o markup

157 |

Sempre que possível, evite elementos pais supérfluos quando escrever HTML. Muitas vezes é necessário uma interação ou refatoração, mas isso produz pouco HTML. Veja o seguinte exemplo:

158 |
159 |
160 | {% highlight html %}{% include html/reducing-markup.html %}{% endhighlight %} 161 |
162 |
163 | 164 |
165 |
166 |

Markup gerado por Javascript

167 |

Escrever código em um arquivos Javascript faz com que o conteúdo seja difícil de ser encontrado, difícil de ser editado e o torna menos performático. Evite fazer isso o máximo possível.

168 |
169 |
170 | 171 |
172 |

CSS

173 |
174 | 175 |
176 |
177 |

Sintaxe do CSS

178 | 196 |

Dúvidas sobre os termos usados aqui? Veja a seção de sintaxe dos CSS na Wikipedia.

197 |
198 |
199 | {% highlight css %}{% include css/syntax.css %}{% endhighlight %} 200 |
201 |
202 | 203 |
204 |
205 |

Ordem das declarações

206 |

Declarações relacionadas devem ser agrupadas segundo a seguinte ordem:

207 |
    208 |
  1. Posicionamento
  2. 209 |
  3. Box model
  4. 210 |
  5. Tipografia
  6. 211 |
  7. Visual
  8. 212 |
213 |

Posicionamento vem primeiro por que isto pode remover um elemento do fluxo normal do documento e substituir estilos relacionados. O box model vem depois pois ele dita as dimensões e lugar do componente.

214 |

Tudo o mais que toma lugar dentro do componente ou não impacta as duas seções anteriores, vem por último.

215 |

Para uma lista completa de propridades e suas ordens, por favor veja Recess,

216 |

Declarações relacionadas devem ser agrupadas, colocando posicionamento e as propriedades de box-model perto do topo, seguido das propriedades de tipografia e depois propriedades visuais.

217 |

Para uma lista completa das propriedades e suas ordens, por favor verifique a página do Recess.

218 |
219 |
220 | {% highlight css %}{% include css/declaration-order.css %}{% endhighlight %} 221 |
222 |
223 | 224 |
225 |
226 |

Onde colocar as Media Queries

227 |

Coloque as Media Queries o mais perto possível de suas regras originais. Não as coloque separadas em outros arquivos ou no final do documento. Se você fizer isso, outros poderão não encontrá-las no futuro. Veja um exemplo típico:

228 |
229 |
230 | {% highlight css %}{% include css/media-queries.css %}{% endhighlight %} 231 |
232 |
233 | 234 |
235 |
236 |

Propriedades com prefixo

237 |

Quando usar prefixos de browsers, idente cada propriedade alinhada verticalmente para facilitar a edição multi-linha.

238 |

No Textmate, use Text → Edit Each Line in Selection (⌃⌘A). No Sublime Text 2, use Selection → Add Previous Line (⌃⇧↑) e Selection → Add Next Line (⌃⇧↓).

239 |
240 |
241 | {% highlight css %}{% include css/prefixed-properties.css %}{% endhighlight %} 242 |
243 |
244 | 245 |
246 |
247 |

Declarações únicas

248 |

Em lugares onde são definidas apenas uma linha de propriedade, considere remover as quebras de linha para melhorar a leitura e edição. Considere este exemplo:

249 |
250 |
251 | {% highlight css %}{% include css/single-declarations.css %}{% endhighlight %} 252 |
253 |
254 | 255 |
256 |
257 |

Propriedades resumidas

258 |

Esforce-se muito para usar declarações de propriedades resumidas onde você define todos os valores dessa propriedade. As propriedades resumidas mais usadas incluem:

259 | 267 |

Frequentemente não precisamos definir todos os valores que uma propriedade representa. Por exemplo, os títulos do HTML tem margens no top e bottom definidas por padrão, então, quando necessário, apenas substitua estes dois valores. O uso excessivo de propriedades resumidas (ou shorthand properties) pode fazer com que o código fique um pouco bagunçado quando substituímos propriedades não utilizadas.

268 |

O Mozilla Developer Network tem um ótimo artigo em shorthand properties para quem não está familiarizado essa forma de escrever.

269 |
270 |
271 | {% highlight css %}{% include css/shorthand.css %}{% endhighlight %} 272 |
273 |
274 | 275 |
276 |
277 |

Aninhamento (nesting) no LESS e SASS

278 |

Evite aninhar seletores (fazer "nesting"). Só porque você pode fazer isso, não significa que você deve fazê-lo sempre. Considere aninhar se você tem um escopo de estilos para um pai e se há múltiplos elementos para serem aninhados.

279 |
280 |
281 | {% highlight scss %}{% include css/nesting.scss %}{% endhighlight %} 282 |
283 |
284 | 285 |
286 |

Legível para humanos

287 |
288 | 289 |
290 |
291 |

Comentários

292 |

Código é escrito e mantido por pessoas. Certifique-se de que o código é descritivo, bem comentado e amigável para os outros. Grandes pedaços de comentários devem ter contexto e não devem apenas reiterar um nome de classe ou componente.

293 |

Certifique-se de escrever em sentenças completas ou grandes comentários e frases sucintas para notas gerais.

294 |
295 |
296 | {% highlight css %}{% include css/comments.css %}{% endhighlight %} 297 |
298 |
299 | 300 |
301 |
302 |

Nomes de classes

303 | 310 |
311 |
312 | {% highlight css %}{% include css/class-names.css %}{% endhighlight %} 313 |
314 |
315 | 316 |
317 |
318 |

Seletores

319 | 324 |

Leitura adicional:

325 | 329 |
330 |
331 | {% highlight css %}{% include css/selectors.css %}{% endhighlight %} 332 |
333 |
334 | 335 |
336 |
337 |

Organização

338 | 343 |
344 |
345 | 346 |
347 |
348 |

Preferências de editor

349 |

Defina seu editor com as seguintes configurações para evitar inconsistências comuns no código e diffs sujos:

350 | 356 | 357 |

Considere documentar e aplicar estas configurações para o seu projeto com o .editorconfig. Para um exemplo, veja o arquivo utilizado no Bootstrap. Aprenda mais em EditorConfig

358 |
359 |
360 | -------------------------------------------------------------------------------- /en.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | --- 4 | 5 | 6 |
7 |

Table of contents

8 |
9 |
10 |
11 |

HTML

12 | 23 |
24 |
25 |

CSS

26 | 39 |
40 |
41 | 42 | 43 |
44 |
45 |

Golden rule

46 |

Enforce these, or your own, agreed upon guidelines at all times. Small or large, call out what's incorrect. For additions or contributions to this Code Guide, please open an issue on GitHub.

47 |
48 |
49 |
50 |

Every line of code should appear to be written by a single person, no matter the number of contributors.

51 |
52 |
53 |
54 | 55 | 56 | 57 |
58 |

HTML

59 |
60 | 61 |
62 |
63 |

Syntax

64 | 70 |
71 |
72 | {% highlight html %}{% include html/syntax.html %}{% endhighlight %} 73 |
74 |
75 | 76 |
77 |
78 |

HTML5 doctype

79 |

Enforce standards mode and more consistent rendering in every browser possible with this simple doctype at the beginning of every HTML page.

80 |
81 |
82 | {% highlight html %}{% include html/doctype.html %}{% endhighlight %} 83 |
84 |
85 | 86 |
87 |
88 |

Character encoding

89 |

Quickly and easily ensure proper rendering of your content by declaring an explicit character encoding.

90 |
91 |
92 | {% highlight html %}{% include html/encoding.html %}{% endhighlight %} 93 |
94 |
95 | 96 |
97 |
98 |

CSS and JavaScript includes

99 |

Per HTML5 spec, typically there is no need to specify a type when including CSS and JavaScript files as text/css and text/javascript are their respective defaults.

100 |

HTML5 spec links

101 | 106 |
107 |
108 | {% highlight html %}{% include html/style-script.html %}{% endhighlight %} 109 |
110 |
111 | 112 |
113 |
114 |

Practicality over purity

115 |

Strive to maintain HTML standards and semantics, but not at the expense of practicality. Use the least amount of markup with the fewest intricacies whenever possible.

116 |
117 |
118 | 119 |
120 |
121 |

Attribute order

122 |

HTML attributes should come in this particular order for easier reading of code.

123 | 129 |

Classes make for great reusable components, so they come first. Ids are more specific and should be used sparingly (e.g., for in-page bookmarks), so they come second.

130 |
131 |
132 | {% highlight html %}{% include html/attribute-order.html %}{% endhighlight %} 133 |
134 |
135 | 136 |
137 |
138 |

Boolean attributes

139 |

A boolean attribute is one that needs no declared value. XHTML required you to declare a value, but HTML5 has no such requirement.

140 |

For further reading, consult the WhatWG section on boolean attributes:

141 |
142 |

The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.

143 |
144 |

If you must include the attribute's value, and you don't need to, follow this WhatWG guideline:

145 |
146 |

If the attribute is present, its value must either be the empty string or [...] the attribute's canonical name, with no leading or trailing whitespace.

147 |
148 |

In short, don't add a value.

149 |
150 |
151 | {% highlight html %}{% include html/boolean-attributes.html %}{% endhighlight %} 152 |
153 |
154 | 155 |
156 |
157 |

Reducing markup

158 |

Whenever possible, avoid superfluous parent elements when writing HTML. Many times this requires iteration and refactoring, but produces less HTML. Take the following example:

159 |
160 |
161 | {% highlight html %}{% include html/reducing-markup.html %}{% endhighlight %} 162 |
163 |
164 | 165 |
166 |
167 |

JavaScript generated markup

168 |

Writing markup in a JavaScript file makes the content harder to find, harder to edit, and less performant. Avoid it whenever possible.

169 |
170 |
171 | 172 | 173 | 174 |
175 |

CSS

176 |
177 | 178 |
179 |
180 |

Syntax

181 | 196 |

Questions on the terms used here? See the syntax section of the Cascading Style Sheets article on Wikipedia.

197 |
198 |
199 | {% highlight css %}{% include css/syntax.css %}{% endhighlight %} 200 |
201 |
202 | 203 |
204 |
205 |

Declaration order

206 |

Related property declarations should be grouped together following the order:

207 |
    208 |
  1. Positioning
  2. 209 |
  3. Box model
  4. 210 |
  5. Typographic
  6. 211 |
  7. Visual
  8. 212 |
213 |

Positioning comes first because it can remove an element from the normal flow of the document and override box model related styles. The box model comes next as it dictates a component's dimensions and placement.

214 |

Everything else takes place inside the component or without impacting the previous two sections, and thus they come last.

215 |

For a complete list of properties and their order, please see Recess.

216 |
217 |
218 | {% highlight css %}{% include css/declaration-order.css %}{% endhighlight %} 219 |
220 |
221 | 222 |
223 |
224 |

Media query placement

225 |

Place media queries as close to their relevant rule sets whenever possible. Don't bundle them all in a separate stylesheet or at the end of the document. Doing so only makes it easier for folks to miss them in the future. Here's a typical setup.

226 |
227 |
228 | {% highlight css %}{% include css/media-queries.css %}{% endhighlight %} 229 |
230 |
231 | 232 |
233 |
234 |

Prefixed properties

235 |

When using vendor prefixed properties, indent each property such that the declaration's value lines up vertically for easy multi-line editing.

236 |

In Textmate, use Text → Edit Each Line in Selection (⌃⌘A). In Sublime Text 2, use Selection → Add Previous Line (⌃⇧↑) and Selection → Add Next Line (⌃⇧↓).

237 |
238 |
239 | {% highlight css %}{% include css/prefixed-properties.css %}{% endhighlight %} 240 |
241 |
242 | 243 |
244 |
245 |

Single declarations

246 |

In instances where a rule set includes only one declaration, consider removing line breaks for readability and faster editing. Any rule set with multiple declarations should be split to separate lines.

247 |

The key factor here is error detection—e.g., a CSS validator stating you have a syntax error on Line 183. With a single declaration, there's no missing it. With multiple declarations, separate lines is a must for your sanity.

248 |
249 |
250 | {% highlight css %}{% include css/single-declarations.css %}{% endhighlight %} 251 |
252 |
253 | 254 |
255 |
256 |

Shorthand notation

257 |

Strive to limit use of shorthand declarations to instances where you must explicitly set all the available values. Common overused shorthand properties include:

258 | 266 |

Often times we don't need to set all the values a shorthand property represents. For example, HTML headings only set top and bottom margin, so when necessary, only override those two values. Excessive use of shorthand properties often leads to sloppier code with unnecessary overrides and unintended side effects.

267 |

The Mozilla Developer Network has a great article on shorthand properties for those unfamiliar with notation and behavior.

268 |
269 |
270 | {% highlight css %}{% include css/shorthand.css %}{% endhighlight %} 271 |
272 |
273 | 274 |
275 |
276 |

Nesting in LESS and SASS

277 |

Avoid unnecessary nesting. Just because you can nest, doesn't mean you always should. Consider nesting only if you must scope styles to a parent and if there are multiple elements to be nested.

278 |
279 |
280 | {% highlight scss %}{% include css/nesting.scss %}{% endhighlight %} 281 |
282 |
283 | 284 |
285 |
286 |

Comments

287 |

Code is written and maintained by people. Ensure your code is descriptive, well commented, and approachable by others. Great code comments convey context or purpose. Do not simply reiterate a component or class name.

288 |

Be sure to write in complete sentences or larger comments and succinct phrases for general notes.

289 |
290 |
291 | {% highlight css %}{% include css/comments.css %}{% endhighlight %} 292 |
293 |
294 | 295 |
296 |
297 |

Class names

298 | 306 |
307 |
308 | {% highlight css %}{% include css/class-names.css %}{% endhighlight %} 309 |
310 |
311 | 312 |
313 |
314 |

Selectors

315 | 321 |

Additional reading:

322 | 326 |
327 |
328 | {% highlight css %}{% include css/selectors.css %}{% endhighlight %} 329 |
330 |
331 | 332 |
333 |
334 |

Organization

335 | 341 |
342 |
343 | {% highlight css %}{% include css/organization-comments.css %}{% endhighlight %} 344 |
345 |
346 | 347 |
348 |
349 |

Editor preferences

350 |

Set your editor to the following settings to avoid common code inconsistencies and dirty diffs:

351 | 357 |

Consider documenting and applying these preferences to your project's .editorconfig file. For an example, see the one in Bootstrap. Learn more about EditorConfig.

358 |
359 |
360 | --------------------------------------------------------------------------------