Dreamweaver 等可視化工具生成的模板常含冗餘、過時代碼。掌握現代 HTML5 標準模板,輕量、語義、無累贅。
<!doctype html>
<html lang="zh-Hant">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>頁面標題</title>
<link rel="stylesheet" href="style.css">
<meta name="description" content="頁面描述">
</head>
<body>
<header><h1>站點標題</h1></header>
<main><p>主要內容</p></main>
<footer>© 2024</footer>
<script src="app.js" defer></script>
</body>
</html>
xmlns="https://www.w3.org/1999/xhtml"(HTML5 不需要)。<meta http-equiv="Content-Type" content="text/html; charset=utf-8">(HTML5 用 <meta charset>)。<style>、<script> 混雜在 head,不利快取與 CSP。language="JavaScript"、type="text/javascript"(HTML5 可省略)。<div> 搭建佈局。| 標籤 | 用途 | 備註 |
|---|---|---|
<br> | 單行換行 | 空元素,無閉合標籤 |
<nobr> | 禁止換行 (棄用) | 改用 CSS white-space: nowrap |
<center> | 居中 (棄用) | 改用 CSS text-align:center / margin:auto |
<p> | 段落 | 語義塊級 |
<header>/<footer>/<main>/<section>/<article>/<aside>/<nav> | 語義區塊 | HTML5 新增,利於 SEO/無障礙 |
<!-- InstanceBeginEditable --> 等)。<table> 佈局殘留。normalize.css / modern-normalize 統一基線。