HTML5 & CSS3 & ES6 速查表

7 阅读6分钟

HTML5 新特性速查表

1. 语义化标签

标签含义示例
<header>页面或区块头部<header>网站标题</header>
<nav>导航区域<nav><a href="#">首页</a></nav>
<main>主内容区<main>主要内容</main>
<article>独立文章/内容块<article>博客正文</article>
<section>文档分区/章节<section>章节内容</section>
<aside>侧边栏/附属信息<aside>广告位</aside>
<footer>页脚<footer>版权信息</footer>
<figure>/ <figcaption>图片+说明组合<figure><img src="a.jpg"><figcaption>图1</figcaption></figure>
<mark>高亮文本<mark>重点</mark>
<time>时间/日期标记<time datetime="2026-03-04">今天</time>
<details>/ <summary>可折叠详情<details><summary>更多</summary>隐藏内容</details>

2. 表单增强

特性含义示例
type="email"邮箱输入验证<input type="email">
type="url"URL 输入验证<input type="url">
type="number"数字输入<input type="number" min="1" max="10">
type="range"滑块输入<input type="range" min="0" max="100">
type="date"/ month/ week日期选择<input type="date">
type="search"搜索框<input type="search">
type="tel"电话输入<input type="tel">
placeholder占位提示文字<input placeholder="请输入">
required必填项<input required>
autocomplete自动填充控制<form autocomplete="on">
pattern正则验证<input pattern="[A-Za-z]{3}">
multiple多选文件/值<input type="file" multiple>
datalist输入建议列表<input list="browsers"><datalist id="browsers"><option>Chrome</option></datalist>

3. 多媒体标签

标签含义示例
<video>视频播放<video src="movie.mp4" controls></video>
<audio>音频播放<audio src="music.mp3" controls></audio>
<source>多格式资源<source src="video.webm" type="video/webm">
<track>字幕/文本轨道<track kind="subtitles" src="sub.vtt">
<embed>嵌入外部内容<embed src="a.swf">
<object>嵌入插件内容<object data="a.pdf" type="application/pdf"></object>

4. 图形与存储

特性含义示例
<canvas>2D 绘图<canvas id="c"></canvas>
<svg>矢量图形<svg width="100" height="100"><circle cx="50" cy="50" r="40"/></svg>
localStorage本地持久化存储localStorage.setItem('key','value');
sessionStorage会话级存储sessionStorage.getItem('key');
indexedDB客户端数据库let db = indexedDB.open('db');
Web Storage键值对存储window.sessionStorage
Drag and Drop API拖放功能draggable="true"
Geolocation API地理位置navigator.geolocation.getCurrentPosition(fn)
Web Workers后台线程new Worker('worker.js')
WebSocket双向通信new WebSocket('ws://...')

CSS3 新特性速查表

1. 选择器增强

选择器含义示例
E:nth-child(n)父元素第 n 个子元素li:nth-child(2){color:red;}
E:nth-of-type(n)同类型第 n 个元素p:nth-of-type(1){font-weight:bold;}
E:first-of-type/ last-of-type同类型首/末元素p:first-of-type{}
E:not(selector)排除匹配元素div:not(.box){}
E::before/ E::after伪元素插入内容div::before{content:"★";}
E[attr^=val]属性值以 val 开头a[href^="https"]{color:green;}
E[attr$=val]属性值以 val 结尾img[src$=".png"]{border:1px solid #000;}
E[attr*=val]属性值包含 vala[href*="example"]{}
E~FE 之后同层 F 元素h1~p{}
E+FE 后紧邻的 F 元素h1+p{}

2. 盒模型与布局

特性含义示例
box-sizing: border-box宽高含 padding 和 borderdiv{box-sizing:border-box;width:100px;padding:10px;}
display: flex弹性布局display:flex;justify-content:center;
display: grid网格布局display:grid;grid-template-columns:1fr 1fr;
gap网格/弹性布局间距gap: 10px;
align-items/ justify-content弹性布局对齐align-items:center;
place-items简写对齐place-items:center;
order改变元素顺序order:2;
float/ clear浮动与清除float:left; clear:both;
position: sticky粘性定位position:sticky; top:0;

3. 动画与过渡

特性含义示例
transition平滑过渡效果transition: all 0.3s ease;
@keyframes定义动画关键帧@keyframes fade{from{opacity:0;}to{opacity:1;}}
animation应用动画animation: fade 2s infinite;
animation-delay动画延迟animation-delay:1s;
animation-fill-mode动画前后状态animation-fill-mode: forwards;

4. 变形与滤镜

特性含义示例
transform旋转/缩放/位移/倾斜transform: rotate(45deg) scale(1.2);
transform-origin变形原点transform-origin: top left;
filter图像滤镜效果filter: blur(5px) grayscale(100%);
backdrop-filter背景滤镜backdrop-filter: blur(10px);

5. 背景与边框

特性含义示例
background-size背景图尺寸background-size: cover;
background-clip背景绘制区域background-clip: text;
background-blend-mode背景混合模式background-blend-mode: multiply;
border-radius圆角border-radius: 10px;
box-shadow盒子阴影box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
border-image图片边框border-image: url(border.png) 30 round;
outline外轮廓线outline: 2px solid red;

6. 媒体查询(响应式设计)

特性含义示例
@media根据设备条件应用样式@media(max-width:768px){body{font-size:14px;}}
min-width/ max-width最小/最大宽度@media(min-width:1200px){}
orientation横竖屏@media(orientation:portrait){}
resolution屏幕分辨率@media(resolution:2dppx){}

7. 其他常用特性(补全)

特性含义示例
calc()计算值width: calc(100% - 20px);
var()CSS 变量--main-color:#333; color: var(--main-color);
clamp()限制范围值font-size: clamp(12px, 2vw, 24px);
mix-blend-mode混合模式mix-blend-mode: overlay;
isolation隔离合成层isolation: isolate;
scroll-behavior平滑滚动scroll-behavior: smooth;
appearance重置控件外观appearance: none;
user-select禁止选中文本user-select:none;
pointer-events禁用鼠标事件pointer-events:none;

ES6 新特性速查表

1. 变量声明

特性含义示例
let块级作用域,可重新赋值let a = 1; a = 2;
const块级作用域,不可重新赋值(对象属性可变)const PI = 3.14;

2. 箭头函数

特性含义示例
=>简洁函数语法,自动绑定外层 thisconst add = (a,b) => a+b;

3. 模板字符串

特性含义示例
` `多行字符串与 ${expr}插值`Hello ${name}`

4. 解构赋值

特性含义示例
数组解构从数组提取值const [x,y] = [1,2];
对象解构从对象提取值const {name} = {name:'Tom'};

5. 默认参数

特性含义示例
默认参数值参数未传时用默认值function f(a=1){}

6. 类语法

特性含义示例
class/ extends面向对象语法class Child extends Parent {}

7. 模块系统

特性含义示例
export/ import模块化导入导出export const a=1;/ import {a} from './mod.js';

8. Promise 异步

特性含义示例
Promise异步操作对象new Promise((resolve,reject)=>{})
.then()/ .catch()处理结果/捕获错误p.then(v=>{}).catch(e=>{})
Promise.all()并行执行,全部成功才成功Promise.all([p1,p2])
Promise.race()取最先完成的 PromisePromise.race([p1,p2])
Promise.allSettled()等待全部完成(不论成败)Promise.allSettled([p1,p2])
Promise.any()任意一个成功即成功Promise.any([p1,p2])

9. 展开运算符 ...

特性含义示例
数组展开拆分数组元素[...arr1, 3]
对象展开合并对象{...obj1, b:2}
函数传参展开数组为参数Math.max(...arr)

10. 剩余参数 ...

特性含义示例
收集剩余参数转为数组function f(a,...rest){}

11. 其他常用特性(补全)

特性含义示例
for...of遍历可迭代对象(数组、Map、Set 等)for(const v of arr){}
Map键值对集合,键可以是任意类型const m = new Map(); m.set('a',1);
Set不重复值的集合const s = new Set([1,2,2]);
Symbol唯一且不可变的值类型const sym = Symbol('desc');
Generator(function*)可暂停的函数function* gen(){ yield 1; }
Proxy拦截对象操作const proxy = new Proxy(obj, handler);
Reflect操作对象的统一 APIReflect.get(obj,'prop');
Array.from()类数组转数组Array.from(arguments)
Array.of()创建数组Array.of(1,2,3)
Object.assign()浅拷贝对象Object.assign({}, obj1)
includes()数组是否包含某元素[1,2].includes(2)
find()/ findIndex()查找元素或索引[1,2].find(x=>x>1)
padStart()/ padEnd()字符串补位'5'.padStart(2,'0')
entries()/ keys()/ values()返回迭代器arr.keys()

12.垃圾回收机制(GC)

只要没有任何变量、属性、作用域等引用它,它就会被自动回收。