HTML语义标签总结

155 阅读1分钟

HTML(超文本标记语言)

(HyperText Markup Language)

HTML的首个公开描述出现于一个名为HTML Tags的文件中,由 蒂姆·伯纳斯-李 于1991年底提及。

HTML功能概述

  • 嵌入图像音乐等多媒体
  • 创建交互表单
  • 结构化信息

    例如标题、段落、列表等,一定程度上描述文档的外观和语义。

HTML文件的初始模板

<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,minimal-ui:ios">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
</body>
</html>

常见的章节标签

<h1> ~ <h6> 标题标签
<section> 章节标签
<article> 文章标签
<p> 段落标签
<header> 头部标签
<footer> 脚部标签
<main> 正文标签
<aside> 副文标签
<div> 分层标签


使用方式如下
  <article>
    <header></header>
    <div>
      <main>
        <section>
          <h1></h1>
          <h2></h2>
          <p></p>
          <h2></h2>
          <p></p>
        </section>
      </main>
      <aside>
        <section>
          <h2></h2>
          <p></p>
        </section>
      </aside>
    </div>
    <footer></footer>
  </article>

全局属性

class
contenteditable
hiden
id
style
tabindex
title

常用的内容标签

<ol> + <li> 有序列表
<ul> + <li> 无序列表
<dl> + <dt> + <dd> 描述列表

<pre> 转义
<a> 超链接
<em> 强调
<strong> 重要
<quote> 引用
<blockquote> 块级引用

<code> 代码
<hr> 分割线
<br> 换行