参考

Google:https://google.github.io/styleguide/htmlcssguide.html

Google

只使用小写字母

  1. <!-- 不推荐 -->
  2. <A HREF="/">Home</A>
  3. <!-- 推荐 -->
  4. <img src="google.png" alt="Google">

根据元素(有时被错误的叫做“标记”)被创造的用途使用他们。

比如,对标题使用标题元素,对段落使用 p 元素,对锚点使用 a 元素等。

  1. <!-- 不推荐 -->
  2. <div onclick="goToRecommendations();">All recommendations</div>
  3. <!-- 推荐 -->
  4. <a href="recommendations/">All recommendations</a>

为多媒体提供替代内容

  1. <!-- 不推荐 -->
  2. <img src="spreadsheet.png">
  3. <!-- 推荐 -->
  4. <img src="spreadsheet.png" alt="Spreadsheet screenshot.">

不要使用实体引用。

  1. <!-- 不推荐 -->
  2. The currency symbol for the Euro is &ldquo;&eur;&rdquo;.
  3. <!-- 推荐 -->
  4. The currency symbol for the Euro is “€”.

对每个块、列表、表格元素都另起一行,每个子元素都缩进

  1. <table>
  2. <thead>
  3. <tr>
  4. <th scope="col">Income
  5. <th scope="col">Taxes
  6. <tbody>
  7. <tr>
  8. <td>$ 5.00
  9. <td>$ 4.50
  10. </table>

断开长行

  1. <md-progress-circular
  2. md-mode="indeterminate"
  3. class="md-accent"
  4. ng-show="ctrl.loading"
  5. md-diameter="35">
  6. </md-progress-circular>