|
1 | | -## HTML |
| 1 | +## html |
2 | 2 |
|
3 | | -@TODO - Add style guide |
| 3 | +These guidelines have been assembled following an examination of emerging practices, ideas and existing styleguides, and include items from: |
| 4 | + |
| 5 | +1. [Google's html styleguide](http://google-styleguide.googlecode.com/svn/trunk/htmlcssguide.xml) |
| 6 | + |
| 7 | +### Protocol |
| 8 | + |
| 9 | +Omit the protocol portion (http:, https:) from URLs pointing to images and other media files, style sheets, and scripts unless they are not available over both protocols. |
| 10 | + |
| 11 | +This prevents mixed content issues and results in minor file size savings. |
| 12 | + |
| 13 | +```html |
| 14 | +<!-- Good --> |
| 15 | +<script src="//www.google.com/js/gweb/analytics/autotrack.js"></script> |
| 16 | +<!-- Bad --> |
| 17 | +<script src="http://www.google.com/js/gweb/analytics/autotrack.js"></script> |
| 18 | +``` |
| 19 | + |
| 20 | +### Type attributes |
| 21 | +Do not use type attributes for style sheets (unless not using CSS) and scripts (unless not using JavaScript). |
| 22 | +```html |
| 23 | +<!-- Good --> |
| 24 | +<link rel="stylesheet" href="//joomla.org/css/main.css"> |
| 25 | + |
| 26 | +<!-- Bad --> |
| 27 | +<link rel="stylesheet" href="//joomla.org/css/main.css" type="text/css"> |
| 28 | +``` |
| 29 | + |
| 30 | +### Capitalisation |
| 31 | +All html should be lowercase; element names, attributes, attribute values (unless text/CDATA), CSS selectors, properties, and property values (with the exception of strings). |
| 32 | + |
| 33 | +```html |
| 34 | +<!-- Good --> |
| 35 | +<img src="joomla.png" alt="Joomla"> |
| 36 | +<!-- Bad --> |
| 37 | +<A HREF="/">Home</A> |
| 38 | +``` |
| 39 | + |
| 40 | +### Formatting |
| 41 | +Use a new line for every block, list, or table element, and indent every such child element. |
| 42 | + |
| 43 | +```html |
| 44 | +<!-- Good --> |
| 45 | +<div> |
| 46 | + <ul> |
| 47 | + <li>Home</li> |
| 48 | + <li>Blog</li> |
| 49 | + </ul> |
| 50 | +</div> |
| 51 | + |
| 52 | +<!-- Bad - ul is a block element --> |
| 53 | +<div><ul> |
| 54 | + <li>Home</li> |
| 55 | + <li>Blog</li> |
| 56 | +</ul></div> |
| 57 | +``` |
| 58 | + |
| 59 | +### Semantics |
| 60 | +Use HTML according to its purpose. For example, use heading elements for headings, p elements for paragraphs, a elements for anchors, etc. |
| 61 | + |
| 62 | +Using HTML according to its purpose is important for accessibility, reuse, and code efficiency reasons. |
| 63 | +```html |
| 64 | +<!-- Good --> |
| 65 | +<a href="subscriptions/">View subscriptions</a> |
| 66 | + |
| 67 | +<!-- Bad - ul is a block element --> |
| 68 | +<div onclick="goToSubscriptions();">View subscriptions</div> |
| 69 | +``` |
| 70 | + |
| 71 | +### Mark todos |
| 72 | +Highlight todos by using the keyword TODO, eg: |
| 73 | + |
| 74 | +```html |
| 75 | +<!-- TODO: add active item class --> |
| 76 | +<ul> |
| 77 | + <li>Home</li> |
| 78 | + <li>Blog</li> |
| 79 | +</ul> |
| 80 | +``` |
0 commit comments