一、html
1. HTML 属性顺序
class id,name data-* src, for, type, href, value title, alt role, aria-*
2.减少标签的数量
3.属性统一为双引号
<div class="class" οnclick="$(this).removeClass('class');console.log('hello')">hello</div>
二、css
1.为选择器分组时,将单独的选择器单独放在一行
2.使用简写、小写形式的十六进制值,便于区分,例如,用 #fff 代替 #FFFFFF
3.选择器中的属性添加双引号,例如,input[type="text"]
4.声明顺序:Positioning Box model Typographic Visual ,比如:position: relative; height: 40px; padding-left: 40px; color#fff;
三、js
1.声明变量必须加上 var关键字
2.语句结尾总是使用分号
3.不要使用with()
4.for-in 循环只用于 object/map/hash 的遍历
5.使用直接量代替构造函数
6.不要修改内置对象, 如 Object.prototype和 Array.prototype的原型
7.字符串使用单引号
8.合理的注释
参考链接:
2.Google JavaScript 编码规范指南
扩展