HTML语义化标签实战:构建SEO友好的现代网页结构
1. 基本文档结构
使用语义化标签定义页面框架:
网站标题
网站副标题或简介
文章标题
文章内容…
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>页面标题</title>
</head>
<body>
<header>
<h1>网站标题</h1>
</header>
<nav>...</nav>
<main>
<article>...</article>
</main>
<footer>...</footer>
</body>
</html>
2. 文章内容语义化
新闻文章的正确标记方法:
<article>
<header>
<h1>文章主标题</h1>
<time datetime="2023-06-15">2023年6月15日</time>
</header>
<section>
<h2>章节标题</h2>
<p>段落内容...</p>
<figure>
<img src="image.jpg" alt="描述文字">
<figcaption>图片说明</figcaption>
</figure>
</section>
<footer>
<p>作者:张三</p>
</footer>
</article>
3. 辅助内容标记
使用<aside>
标记相关内容:
<aside>
<h3>相关阅读</h3>
<ul>
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >相关文章1</a></li>
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >相关文章2</a></li>
</ul>
</aside>
标签 | 用途 | SEO价值 |
---|---|---|
<header> | 页眉或内容头部 | 高 |
<nav> | 导航链接 | 中 |
<article> | 独立内容块 | 高 |
<section> | 文档章节 | 中 |
<time> | 时间日期 | 低 |
4. 微数据与SEO优化
使用Schema.org微数据增强SEO:
<article itemscope itemtype="http://schema.org/NewsArticle">
<h1 itemprop="headline">文章标题</h1>
<div itemprop="author" itemscope itemtype="http://schema.org/Person">
作者:<span itemprop="name">李四</span>
</div>
<time itemprop="datePublished" datetime="2023-06-15">2023年6月15日</time>
<div itemprop="articleBody">
文章内容...
</div>
</article>
通过合理使用HTML5语义化标签,可以创建出既对搜索引擎友好又具备良好可访问性的网页结构,为网站带来更好的用户体验和搜索排名。