├── .gitignore ├── CNAME ├── LICENSE.md ├── README.md ├── _config.yml ├── _includes ├── ads.css ├── css │ ├── class-names.css │ ├── comments.css │ ├── declaration-order.css │ ├── import.html │ ├── media-queries.css │ ├── nesting.scss │ ├── organization-comments.css │ ├── organization-files.txt │ ├── prefixed-properties.css │ ├── selectors.css │ ├── shorthand.css │ ├── single-declarations.css │ └── syntax.css ├── footer.html ├── header.html ├── html │ ├── attribute-order.html │ ├── boolean-attributes.html │ ├── doctype.html │ ├── encoding.html │ ├── ie-compatibility-mode.html │ ├── lang.html │ ├── naming.html │ ├── reducing-markup.html │ ├── style-script.html │ └── syntax.html ├── js.html ├── syntax.css └── tweet-button.html ├── _layouts └── default.html ├── font ├── fontello.eot ├── fontello.svg ├── fontello.ttf └── fontello.woff ├── index.md └── wtf.css /.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 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | wtfhtmlcss.com -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Mark Otto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WTF, HTML and CSS? 2 | 3 | **WTF, HTML and CSS?** is a list of reasons HTML and CSS might make you say what the fuck. It's a curated list of commonly frustrating HTML and CSS quandaries, miscues, and dilemmas, created with the goal of making them *less* common. 4 | 5 | **[Start reading ☞](http://wtfhtmlcss.com)** 6 | 7 | --- 8 | 9 | ### Contribute 10 | 11 | Open an issue or a pull request to suggest changes or additions. 12 | 13 | 14 | ### License 15 | 16 | [MIT licensed.](LICENSE.md) Copyright 2014 @mdo. 17 | 18 | ### Translations 19 | 20 | Translations are maintained by their creators and may not always be up to date with the original here. 21 | 22 | - [French](http://mathieuhays.github.io/wtf-html-css/) - Translated by [mathieuhays](https://github.com/mathieuhays) 23 | - [Italian](http://uncasually.github.io/wtf-html-css/) - Translated by [uncasually](https://github.com/uncasually) 24 | - [Japan](http://makotot.github.io/wtf-html-css/) - Translated by [makotot](https://github.com/makotot) 25 | - [Korean](http://snack-x.github.io/wtf-html-css/) - Translated by [Snack](https://github.com/Snack-X) 26 | - [Portuguese](http://webfatorial.github.io/wtf-html-css/) - Translated by [webfatorial](http://webfatorial.com/) 27 | - [Spanish](http://uncasually.github.io/wtf-html-y-css/) - Translated by [uncasually](https://github.com/uncasually) 28 | - [Russian](http://elforastero.github.io/wtf-html-css/) - Translated by [ElForastero](https://github.com/elforastero) 29 | - [Chinese Simplified](https://lizheming.github.io/wtf-html-css/) - Translated by [lizheming](https://github.com/lizheming) 30 | 31 | Have a translation you'd like to link to? Open a pull request to add it here. Be sure to keep it alphabetical. 32 | 33 | <3 34 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | name: "WTF, HTML and CSS?" 2 | url: http://wtfhtmlcss.com 3 | repo: https://github.com/mdo/wtf-html-css 4 | twitter: https://twitter.com/mdo 5 | 6 | markdown: redcarpet 7 | permalink: pretty 8 | pygments: true 9 | -------------------------------------------------------------------------------- /_includes/ads.css: -------------------------------------------------------------------------------- 1 | /* Ads 2 | -------------------------------------------------- */ 3 | 4 | #carbonads { 5 | display: block; 6 | padding: 2rem 0; 7 | overflow: hidden; /* clearfix */ 8 | font-size: .85rem; 9 | line-height: 1.3; 10 | background-color: #fff; 11 | border-bottom: 1px solid #eee; 12 | } 13 | .carbon-text, 14 | .carbon-poweredby { 15 | display: block; 16 | color: #999; 17 | } 18 | .carbon-text:hover, 19 | .carbon-poweredby:hover { 20 | color: #08c; 21 | text-decoration: none; 22 | } 23 | .carbon-img { 24 | float: left; 25 | margin-right: 1rem; 26 | } 27 | .carbon-poweredby { 28 | display: block !important; 29 | margin-top: .5rem; 30 | } 31 | 32 | @media (min-width: 50rem) { 33 | #carbonads { 34 | position: fixed; 35 | left: 0; 36 | bottom: 0; 37 | width: 7rem; 38 | padding: 1.5rem; 39 | margin: 0; 40 | font-size: .6rem; 41 | border-bottom: 0; 42 | } 43 | .carbon-img { 44 | float: none; 45 | display: block; 46 | margin-bottom: .5rem; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /_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/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/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 | -------------------------------------------------------------------------------- /_includes/css/import.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /_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/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-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 modifier */ 17 | .element-heading { ... } 18 | -------------------------------------------------------------------------------- /_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/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/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 | -------------------------------------------------------------------------------- /_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/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/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/footer.html: -------------------------------------------------------------------------------- 1 | 23 | -------------------------------------------------------------------------------- /_includes/header.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |

{{ site.name }}

5 |

Reasons HTML and CSS might make you say what the fuck. A curated list of commonly frustrating HTML and CSS quandaries, miscues, and dilemmas.

6 |

Created by @mdo.

7 | 8 | 16 |
17 |
18 | -------------------------------------------------------------------------------- /_includes/html/attribute-order.html: -------------------------------------------------------------------------------- 1 | 2 | Example link 3 | 4 | 5 | 6 | 7 | ... 8 | -------------------------------------------------------------------------------- /_includes/html/boolean-attributes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /_includes/html/doctype.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /_includes/html/encoding.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /_includes/html/ie-compatibility-mode.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /_includes/html/lang.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /_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/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/js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /_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 | -------------------------------------------------------------------------------- /_includes/tweet-button.html: -------------------------------------------------------------------------------- 1 |
2 | Tweet 3 |
4 | -------------------------------------------------------------------------------- /_layouts/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | {{ site.name }} 11 | 12 | 13 | 14 | 15 | 16 | 24 | 25 | 26 | 27 | {% include header.html %} 28 | 29 |
30 | 31 | 32 | {{ content }} 33 |
34 | 35 | {% include footer.html %} 36 | 37 | {% include js.html %} 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /font/fontello.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdo/wtf-html-css/9854fa65d7f5263f1e54c828e7a90c84ea356284/font/fontello.eot -------------------------------------------------------------------------------- /font/fontello.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copyright (C) 2014 by original authors @ fontello.com 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /font/fontello.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdo/wtf-html-css/9854fa65d7f5263f1e54c828e7a90c84ea356284/font/fontello.ttf -------------------------------------------------------------------------------- /font/fontello.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdo/wtf-html-css/9854fa65d7f5263f1e54c828e7a90c84ea356284/font/fontello.woff -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | --- 4 | 5 | ### Contents 6 | 7 | - [Declare a doctype](#doctype) 8 | - [Box model math](#box-model-math) 9 | - [Rem units and Mobile Safari](#rems-mobile-safari) 10 | - [Floats first](#floats-first) 11 | - [Floats and clearing](#floats-clearing) 12 | - [Floats and computed height](#floats-computed-height) 13 | - [Floated are block level](#floats-block-level) 14 | - [Vertical margins often collapse](#vertical-margins-collapse) 15 | - [Styling table rows](#styling-table-rows) 16 | - [Firefox and `` buttons](#buttons-firefox) 17 | - [Firefox inner outline on buttons](#buttons-firefox-outline) 18 | - [Always set a `type` on `