← 返回完整题库
HTML简单

HTML5 有哪些新特性?

参考答案

按类别列举,面试时挑重点 + 一句应用场景。

1. 语义化标签

header、footer、nav、main、article、section、aside、figure/figcaption、mark、time。好处:结构清晰、SEO、无障碍。

2. 表单增强

  • 新 type:email、url、tel、number、range、date/time、color、search;
  • 新属性:placeholder、required、pattern、autofocus、multiple、min/max/step、form(表单外关联);
  • 新元素:datalist(输入联想)、output、progress、meter;
  • 原生校验 API:checkValidity()、setCustomValidity()、:valid/:invalid 伪类。

3. 多媒体与图形

<video>/<audio> + source/track(字幕);canvas 2D 绘图;内联 SVG;WebGL/WebGPU 配套。

4. 存储与离线

localStorage/sessionStorage、IndexedDB、Cache API + Service Worker(早期 AppCache 已废弃)。

5. 通信

WebSocket、Server-Sent Events、WebRTC、postMessage、BroadcastChannel、MessageChannel。

6. 设备与文件

Geolocation、Drag & Drop、File/FileReader/Blob/FormData、Notification、DeviceOrientation、requestAnimationFrame。

7. 其他重要能力

  • History API(pushState/replaceState)支撑 SPA 路由;
  • Web Worker(多线程);
  • template、dialog、details/summary、contenteditable;
  • data-* 自定义属性、自定义元素/Shadow DOM(Web Components);
  • 统一错误处理与标准化解析算法、一行 DOCTYPE;
  • 资源预加载(preload/prefetch/preconnect)、async/defer。

8. 已废弃/移除

font、center、big、frame/frameset、acronym、applet;AppCache 移除。

回答技巧

按「标记 → 媒体/图形 → 存储 → 通信 → 设备 → 性能/并发」分组,每组配一个实际用途;最后补一句「HTML5 是活标准,新能力持续加入(如 dialog、fetchpriority、content-visibility)」。

本题来自 计算机知识面试题库,共 921 道题。