萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> 網頁製作 >> HTML5 教學

HTML5 標準頁面模板:語意化結構、CSS Reset 與響應式基礎架構

最小化標準模板

<!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; }
copyright © 萬盛學電腦網 all rights reserved