HTML入门笔记1

83 阅读1分钟

HTML产生

1990年由Tim Berners-Lee 李爵士发明

HTML起手式

<!-- 文档类型 -->
<!DOCTYPE html>
<!-- 设置为zh-CN 中文-->
<html lang="zh-CN">
<head>
    <!-- 文字字符编码 -->
    <meta charset="UTF-8">
    <!-- 禁用缩放 兼容手机-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- ie使用最新内核 -->
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
  • 标题h1-h6
  • 章节section
  • 文章article
  • 段落p
  • 头部header
  • 脚部footer
  • 主要内容main
  • 旁支内容aside

eg.

<body>
    <!-- 章节标签 -->
    <header>顶部广告</header>
    <div>
        <h1>文章标题</h1>
        <section>
            <h2>第一章</h2>
            <p>第一章的内容</p>
        </section>
        <section>
            <h2>第二章</h2>
            <section>
                <h3>2.1</h3>
                <p>2.1内容</p>
            </section>
            <section>
                <h3>2.2</h3>
                <p>2.2内容</p>
            </section>
        </section>
        <!-- 旁支内容aside 一般放些导航-->
        <aside>参考资料1 2 3</aside>
    </div>
    <!-- &copy; 版权标志 -->
    <footer>&copy;版权所有</footer>
</body>

全局属性

  • class
  • hidden
  • id(最好不要用)
  • style(js可以覆盖掉它)
  • tabindex(控制tab的顺序 0是最后一个 -1是指不被tab访问)
  • title(鼠标移上去会显示完整内容 如当文本溢出省略时可用)
  • contenteditable(使用户可以自己编辑)

常用内容标签

  • ol+li(有序列表)
  • ul+li(无序列表)
  • dl+dt+dd (描述列表 dt为描述对象 dd为描述内容)
  • pre(使空格tab换行等正常显示)
  • a(链接)
  • hr(分割线)
  • br(换行)
  • em(强调语气 默认是斜体)
  • strong(内容强调 加粗)
  • quote(引用 默认没有样式 内联)
  • blockquote  (块级 会有换行缩进)
  • code(使代码英文字体等宽)