The quick brown fox jumps over the lazy dog.
- +The quick brown fox jumps over the lazy dog.
```
-Self-closing (void) elements should not be closed. Trailing forward slashes and spaces should be omitted.
+可以自我閉合(Self-closing)的元素不應該有閉合標籤,結尾的斜線以及空白必須忽略。
+
```html
-
+
-
+
```
-### Formatting
-Use a new line for every block, list, or table element, and indent every such child element.
+### 格式
+每個區塊標籤(div, list 或 table)都應該使用單獨的一行,並在每一個子元素縮排。
```html
-
+
@@ -211,13 +217,13 @@ Tip: configure your editor to "show invisibles". This will allow you to eliminat ``` -### Indentation -Don't indent inside html, body, script, or style. Indent inside head and all other elements. -Indent by four spaces at a time. Don’t use tabs or mix tabs and spaces for indentation. +### 縮排 +html、body、script 或 style 等等的標籤底下不需要縮排。head 以及任何其他的標籤底下都需縮排。 +縮排一次是四個空白。不要使用 tab 縮排或是把 tab 和空白混著使用。 ```html - + @@ -246,72 +252,77 @@ Indent by four spaces at a time. Don’t use tabs or mix tabs and spaces for ind ``` -### Trailing Whitespace -Remove trailing white spaces. Trailing white spaces are unnecessary and can complicate diffs. +### 後綴空白 + +移除後綴的空白。後綴空白是不必要的而且會造成複雜的 diffs 顯示. ```html - +Yes please.
- +No, thank you.
``` ### Entity References -Do not use entity references. There is no need to use entity references like —, ”, or ☺, assuming the same encoding (UTF-8) is used for files and editors as well as among teams. -The only exceptions apply to characters with special meaning in HTML (like < and &) as well as control or “invisible” characters (like no-break spaces). +不要使用字符實體引用(entity references)。若開發團隊中每位成員的編輯器編碼都相同的話(都為UTF-8),便不需要使用例如 —、” 或 ☺。 + +唯有的例外是,當該字符在 HTML 之中具有特殊意義 (如 < 和 &)、控制碼或屬於 "看不見 (invisible) " 的字元時(像是 ``` ``` non-breaking spaces) + ```html - +The currency symbol for the Euro is “€”.
- +The currency symbol for the Euro is “&eur;”.
``` -### Inline CSS +### 行內樣式(Inline CSS) + +不要使用行內樣式。當使用 JavaScript 去改變樣式或狀態時,如果可以,儘量使用 Unobtrusive JavaScript(一種將Javascript從HTML結構抽離的設計概念)的模式去改變或新增 class 名稱。 -Inline CSS must be avoided. When altering states using JavaScript, use CSS to define your states, and only use onobtrusive JavaScript to alter class names whenever possible. ```html - + Home - + Home ``` @todo more meaningful example. -### Style Attributes -You should not use border, align, valign, or clear attributes. Avoid use of style attributes, except where using syndicated content or internal syndicating systems. +### Style 屬性 + +你不應該使用 border、align、valign 或 clear 等等的屬性。不要使用 style 屬性。避免使用 style 屬性,除非使用 syndicated content 或 internal syndicating systems。 +### 語意化 -### Semantics -Use HTML according to its purpose. For example, use heading elements for headings, p elements for paragraphs, a elements for anchors, etc. +根據其意義使用 HTML。舉例來說,使用標題元素(h1 ~ h6)來表示標題,段落元素 p 表示段落,連結元素 a 表示連結等等。 + +依據不同的考量來使用 HTML 對於易使用性、重複使用性以及程式碼效率等等是相當重要的。 -Using HTML according to its purpose is important for accessibility, reuse, and code efficiency reasons. ```html - + View subscriptions - +View subscriptions``` +### 標記(Markup) - -### Markup - -#### Image Tags -Image elements () must have an alt attribute. Height and width attributes are optional and may be omitted. +#### 圖片標籤 +圖片元素 (
) 必須包含 alt 屬性. Height 和 width 屬性是可選的,可以被忽略。 @todo add examples from here http://www.bbc.co.uk/guidelines/futuremedia/technical/semantic_markup.shtml -### Comments +### 註解 @todo: comment styles in JS, CSS, HTML -For more complex blocks of HTML, it may be useful to add a comment to the closing tag: +HTML 中複雜的區塊可以在結束標籤之後加上一段註解: + ```html
@@ -321,10 +332,8 @@ For more complex blocks of HTML, it may be useful to add a comment to the closin``` - - -### Mark todos -Highlight todos by using the keyword TODO, eg: +### 在檔案中標記 Todo +在檔案中註解待完成清單時可以使用 TODO 關鍵字,例如: ```html @@ -334,9 +343,7 @@ Highlight todos by using the keyword TODO, eg: ``` - - -### Markup validation tools +### 標記驗證工具 @todo: list various testing tools: * http://validator.w3.org/nu/ * http://csslint.net/