<!DOCTYPE html>
<html lang="zh-Hant">
<head>
<meta charset="UTF-8">
<title>HTML5 語義化結構實戰 | 我的部落格</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="深度解析 HTML5 語義化標籤在實際頁面中的應用模式...">
<link rel="stylesheet" href="/css/main.css">
</head>
<body>
<header class="site-header">
<nav class="main-nav" aria-label="主導航">
<ul><li><a href="/">首頁</a></li><li><a href="/articles">文章</a></li></ul>
</nav>
</header>
<main id="main-content">
<article>
<header>
<h1>HTML5 語義化結構實戰指南</h1>
<div class="meta">
<time datetime="2024-01-15">2024 年 1 月 15 日</time>
<address>作者:<a rel="author" href="/author/zhangsan">張三</a></address>
</div>
</header>
<figure>
<img src="/img/html5-semantic.jpg" alt="HTML5 語義化標籤關係圖" width="800" height="450" loading="lazy">
<figcaption>圖 1:HTML5 核心語義化標籤巢狀關係</figcaption>
</figure>
<section aria-labelledby="sec-structure">
<h2 id="sec-structure">頁面級結構標籤</h2>
<p>...</p>
</section>
<section aria-labelledby="sec-form">
<h2 id="sec-form">增強型表單</h2>
<p>...</p>
</section>
<footer>
<p>© 2024 張三. 采用 CC BY-NC 4.0 授權.</p>
</footer>
</article>
<aside aria-labelledby="aside-title">
<h2 id="aside-title">相關推薦</h2>
<nav>
<ul><li><a href="/article/html5-forms">HTML5 表單深度解析</a></li></ul>
</nav>
</aside>
</main>
<footer class="site-footer">
<p>© 2024 My Blog. All rights reserved.</p>
</footer>
</body>
</html>
<form id="register-form" novalidate>
<div class="field">
<label for="email">電子郵箱</label>
<input type="email" id="email" name="email" required autocomplete="email" placeholder="you@example.com">
<span class="error" aria-live="polite"></span>
</div>
<div class="field">
<label for="password">密碼</label>
<input type="password" id="password" name="password" required minlength="8" autocomplete="new-password">
<span class="hint">至少 8 位,含大小寫、數字、特殊符號</span>
</div>
<div class="field">
<label for="birthdate">出生日期</label>
<input type="date" id="birthdate" name="birthdate" max="2006-12-31">
</div>
<div class="field">
<label for="avatar">頭像</label>
<input type="file" id="avatar" name="avatar" accept="image/*" capture="environment">
</div>
<div class="field">
<label for="theme">主題色</label>
<input type="color" id="theme" name="theme" value="#3b82f6">
</div>
<button type="submit">創建賬號</button>
</form>
<script>
const form = document.getElementById('register-form');
form.addEventListener('submit', e => {
if (!form.checkValidity()) { e.preventDefault(); form.reportValidity(); return; }
const fd = new FormData(form);
fetch('/api/register', { method:'POST', body:fd })
.then(r => r.json())
.then(data => { /* 跳轉或提示 */ });
});
</script>
<!-- 視頻:多編碼回退 + 字幕 + 預載策略 + 響應式 -->
<video controls preload="metadata" poster="/img/poster.webp" width="1280" height="720">
<source src="/media/video.av1.mp4" type="video/mp4; codecs=av01.0.05M.08">
<source src="/media/video.hevc.mp4" type="video/mp4; codecs=hev1.1.6.L93.90">
<source src="/media/video.vp9.webm" type="video/webm; codecs=vp09.00.10.08">
<source src="/media/video.h264.mp4" type="video/mp4">
<track kind="subtitles" src="/media/video.zh.vtt" srclang="zh" label="中文" default>
<track kind="subtitles" src="/media/video.en.vtt" srclang="en" label="English">
您的瀏覽器不支援 HTML5 視頻播放。
</video>
<!-- 響應式圖片:Art Direction + 格式回退 -->
<picture>
<source media="(max-width: 480px)" srcset="/img/hero-mobile.avif" type="image/avif">
<source media="(max-width: 480px)" srcset="/img/hero-mobile.webp" type="image/webp">
<source srcset="/img/hero-desktop.avif" type="image/avif">
<source srcset="/img/hero-desktop.webp" type="image/webp">
<img src="/img/hero-desktop.jpg" alt="Hero 圖片" width="1920" height="1080" loading="eager" fetchpriority="high">
</picture>
<canvas id="chart" width="600" height="300" aria-label="銷售趨勢圖:Q1 120, Q2 150, Q3 180, Q4 210">
不支援 Canvas 的瀏覽器請升級。
</canvas>
<script>
const canvas = document.getElementById('chart');
const ctx = canvas.getContext('2d');
const data = [120, 150, 180, 210];
const max = Math.max(...data);
const barW = 80, gap = 40, bottom = 30, left = 50;
ctx.font = '14px system-ui';
ctx.fillStyle = '#374151';
ctx.textAlign = 'center';
ctx.textBaseline = 'top';
data.forEach((val, i) => {
const h = (val / max) * (canvas.height - bottom - 40);
const x = left + i * (barW + gap) + barW / 2;
const y = canvas.height - bottom - h;
// 柱狀
ctx.fillStyle = '#3b82f6';
ctx.fillRect(x - barW/2, y, barW, h);
// 數值
ctx.fillStyle = '#111827';
ctx.fillText(val, x, y - 20);
// 季度標籤
ctx.fillText(`Q${i+1}`, x, canvas.height - bottom + 10);
});
</script>
HTML5 重新定義了 Web 平台能力邊界。系統學習、大量實戰、持續跟進 Living Standard,才能駕馭現代 Web 開發的全棧挑戰。