统一两个空格缩进
HTML 文件必须加上 DOCTYPE 声明,并统一使用 HTML5 的文档声明:
1 <!DOCTYPE html>
1 <meta charset="utf-8">
1 <!-- 页面关键词 --> 2 <meta name ="keywords" content =""/> 3 <!-- 页面描述 --> 4 <meta name ="description" content =""> 5 <!-- 网页作者 --> 6 <meta name ="author" content ="">
1 <meta http-equiv ="X-UA-Compatible" content ="IE = edge,chrome = 1">
1 <!-- device-width 是指这个设备最理想的 viewport 宽度 --> 2 <!-- initial-scale=1.0 是指初始化的时候缩放大小是1,也就是不缩放 --> 3 <!-- user-scalable=0 是指禁止用户进行缩放 --> 4 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
1 <meta name="format-detection" content="telephone=no">
html 标签分为以下几类:
普通标签使用小写,外部引入的组件标签使用大写
1 <div></div> 2 <el-button><el-button> 3 <Pagination />
<x-tags>
、<my-element>
和<my-awesome-app>
都是正确的名字,而<tabs>
和<foo_bar>
是不正确的。这样的限制使得 HTML 解析器可以分辨那些是标准元素,哪些是自定义元素1 <input type="text" name="title" />
不要让非内容信息污染了你的 HTML,打乱了 HTML 结构。可以使用:before、:after 等伪类元素
HTML 代码
1 <!-- That is clean markup! --> 2 <span class="text-box"> 3 See the square next to me? 4 </span>
CSS 代码:
1 /* We use a :before pseudo element to solve the design problem of placing a colored square in front of the text content */ 2 .text-box:before { 3 content: ‘‘; 4 display: inline-block; 5 width: 1rem; 6 height: 1rem; 7 background-color: red; 8 }
符号 | 描述 | 转义符 |
---|---|---|
空格 | |
|
< | 小于 | < |
> | 大于 | > |
& | 和 | & |
" | 引号 | " |
使用 type=“tel” 而不是 type=“number”
1 <input type="tel">
单行注释
1 <!-- Comment Text --> 2 <div>...</div>
模块注释
1 注释内容前后各一个空格字符 2 <!-- S Comment Text -->表示模块开始 3 <!-- E Comment Text -->表示模块结束,模块与模块之间相隔一行 4 模块注释内部嵌套模块注释,<!-- /Comment Text -->
1 <!-- S Comment Text A --> 2 <div class="mod_a"> 3 4 <div class="mod_b"> 5 ... 6 </div> 7 <!-- /mod_b --> 8 9 <div class="mod_c"> 10 ... 11 </div> 12 <!-- /mod_c --> 13 14 </div> 15 <!-- E Comment Text A --> 16 17 <!-- S Comment Text D --> 18 <div class="mod_d"> 19 ... 20 </div> 21 <!-- E Comment Text D -->
原文:https://www.cnblogs.com/hzn1995/p/14687547.html