Open soonfy opened 6 years ago
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
@import 'https://fonts.googleapis.com/css?family=Open+Sans';
使用 2 个空格缩进
<ul> <li>Fantastic <li>Great </ul>
.example { color: blue; }
全部使用小写
<img src="google.png" alt="Google">
color: #e5e5e5;
移除末尾空格
document type 使用 html5
不用关闭空标签 <!DOCTYPE html> <br>
不用关闭空标签
<!DOCTYPE html> <br>
验证 html 标签
<!DOCTYPE html> <meta charset="utf-8"> <title>Test</title> <article>This is only a test.</article>
语义化标签
<a href="recommendations/">All recommendations</a>
多媒体元素添加替代文本
<img src="spreadsheet.png" alt="Spreadsheet screenshot.">
分开 html,css,js
不使用实体引用
The currency symbol for the Euro is “€”.
省略选择性标签
<!DOCTYPE html> <title>Saving money, saving bytes</title> <p>Qed.
省略 type 属性
<link rel="stylesheet" href="https://www.google.com/css/maia.css"> <script src="https://www.google.com/js/gweb/analytics/autotrack.js"></script>
块级元素,列表,表格缩进单独使用一行
<blockquote> <p><em>Space</em>, the final frontier.</p> </blockquote> <ul> <li>Moe <li>Larry <li>Curly </ul> <table> <thead> <tr> <th scope="col">Income <th scope="col">Taxes <tbody> <tr> <td>$ 5.00 <td>$ 4.50 </table>
断行缩进 4 个字符
<md-progress-circular md-mode="indeterminate" class="md-accent" ng-show="ctrl.loading" md-diameter="35"> </md-progress-circular>
双引号包含属性值
<a class="maia-button maia-button-secondary">Sign in</a>
验证 css
使用有意义的或者通用的 id 或者类名
#gallery {} #login {} .video {} .aux {} .alt {}
id 或者类名要短而有意义
#nav {} .author {}
不要把 id 或者类与元素混合使用
#example {} .error {}
尽量使用速记属性
font: 100%/1.6 palatino, georgia, serif; padding: 0 1em 2em;
属性值 0 后不使用单位
margin: 0
省略前置 0
margin: .5em
尽量使用 3 个字符的 16 进制
color: #fff
有意义的前缀
.mani-note {}
属性名用连字符分隔
name-id: {}
避免使用用户代理的 css hacks
字母声明顺序
background: fuchsia; border: 1px solid; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; color: black; text-align: center; text-indent: 2em;
缩进块级内容
@media screen, projection { html { background: #fff; color: #444; }
}
3. 每条声明最后添加分号 ```css .test { display: block; height: 100px; }
声明冒号后添加空格
h3 { font-weight: bold; }
选择器和声明之间添加空格
#video { margin-top: 1em; }
每个选择器单独占一行
h1, h2, h3 { font-weight: normal; line-height: 1.2; }
每条规则占一行,声明之间添加一个空行
html { background: #fff; }
body { margin: auto; width: 50%; }
8. 规则中使用单引号,url 中不使用引号 ```css @import url(https://www.google.com/css/maia.css); html { font-family: 'open sans', arial, sans-serif; }
/* header */
google html/css style
soonfy
通用规则
协议
风格
使用 2 个空格缩进
全部使用小写
移除末尾空格
基本信息
html
风格
document type 使用 html5
验证 html 标签
语义化标签
多媒体元素添加替代文本
分开 html,css,js
不使用实体引用
省略选择性标签
省略 type 属性
格式
块级元素,列表,表格缩进单独使用一行
断行缩进 4 个字符
双引号包含属性值
css
风格
验证 css
使用有意义的或者通用的 id 或者类名
id 或者类名要短而有意义
不要把 id 或者类与元素混合使用
尽量使用速记属性
属性值 0 后不使用单位
省略前置 0
尽量使用 3 个字符的 16 进制
有意义的前缀
属性名用连字符分隔
避免使用用户代理的 css hacks
格式
字母声明顺序
缩进块级内容
}
声明冒号后添加空格
选择器和声明之间添加空格
每个选择器单独占一行
每条规则占一行,声明之间添加一个空行
body { margin: auto; width: 50%; }
基本信息
参考
google html/css style
soonfy