HTML基础

153 阅读1分钟

祖师爷

Tim Berners-Lee,祖师爷在上,赏口饭吃。

HTML 起手式

Emmet!

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie-edge">
    <title>Document</title>
</head>
<body>
</body>
</html>
  • <meta name="viewport" content="width=device-width, initial-scale=1.0"> 禁用缩放,兼容手机

  • <meta http-equiv="X-UA-Compatible" content="ie-edge"> 告诉IE使用最新内核

章节的标签

  1. 标题 h1-h6
  2. 章节 section
  3. 文章 article
  4. 段落 p
  5. 头部 header
  6. 脚部 footer
  7. 主要内容 main
  8. 旁支内容 aside
  9. 划分 div

全局属性

  1. class
  2. contenteditable
  • 可编辑的,可用于做编辑器
  1. hidden
  2. id
  • 尽量少用,重复编辑器不会提示,可能会导致出错
  1. style
  • JS设置样式优先级 > 行内 style 属性 > style 标签
  1. tabindex
  • 设置 tab 键标记的顺序,可以不连续。tabindex=0:最后访问, tabindex=-1:不访问
  1. title
  • 鼠标悬停时显示的提示内容

内容标签

  1. ol+li (ordered list + list item)
  2. ul+li (unordered list + list item)
  3. dl+dt+dd (description list + term +data)
  4. pre (preview)
  5. hr 分隔线
  6. br (break) 换行
  7. a (anchor)
  8. em (emphasis) 语气,默认样式斜体
  9. strong 本质,默认样式粗体
  10. code
  11. q (quote) 引用
  12. blockquote 换行引用