最小化標準模板
<!DOCTYPE html>
<html lang="zh-Hant">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>頁面標題</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header></header>
<main></main>
<footer></footer>
<script src="app.js" defer></script>
</body>
</html>
現代 CSS Reset(精簡版)
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { line-height: 1.5; font-family: system-ui, sans-serif; }
img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
語意化佈局結構對照表
| 標籤 | 用途 | 典型內容 |
<header> | 頁首/區塊標題 | Logo、導航、搜尋 |
<nav> | 主要導航 | 選單連結群 |
<main> | 主內容(唯一) | 文章、產品列表 |
<article> | 獨立完整內容 | 部落格文、新聞 |
<section> | 主題區塊 | 章節、功能區 |
<aside> | 側邊/輔助內容 | 側欄、相關連結 |
<footer> | 頁尾/區塊尾 | 版權、聯絡、地圖 |
實用工具類別(可直接複製到專案)
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.flex { display: flex; } .flex-col { flex-direction: column; }
.gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.text-center { text-align: center; } .text-left { text-align: left; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }