发明者

蒂姆·伯纳斯-李 (Tim Berners Lee)

起手式

  1. <!DOCTYPEhtml>
  2. <htmllang="en">
  3. <head>
  4. <metacharset="UTF-8">
  5. <metahttp-equiv="X-UA-Compatible"content="IE=edge">
  6. <metaname="viewport"content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. </head>

常用标签

h1-h6

The HTML Section Heading elements 章节标题

  1. <h1>Beetles</h1>
  2. <h2>External morphology</h2>

section

The Generic Section element
一般的章节元素,常见的文章的一段

  1. <h1>Choosing an Apple</h1>
  2. <section>
  3. <h2>Introduction</h2>
  4. <p>This document provides a guide to help with the important task of choosing the correct Apple.</p>
  5. </section>

article

The Article Contents element 用于表示独立的内容,常用新闻、论坛文章、杂志、博客、用户发言等

main

表示body元素中最重要的部分

  1. <header>Gecko facts</header>
  2. <main>
  3. <p>Geckos are a group of usually small, usually nocturnal lizards. They are found on every continent except Australia.</p>
  4. <p>Many species of gecko have adhesive toe pads which enable them to climb walls and even windows.</p>
  5. </main>

aside

常用于侧边栏,和文章主内容没有直接关联

全局属性

class

类名,一个元素可以写多个。方便css和js通过类选择器(class selector)或者dom方法进行操作

id

定义唯一标识符(ID),该标识符在整个文档中必须是唯一的。但是不严谨的写成不唯一也不报错,慎用

style

样式

tabindex

三点需要注意

  • tabindex 可以是 0,表示最后才被 tab 访问
  • tabindex 可以是 -1,表示不可被 tab 访问
  • tabindex 可以是正数,不必是连续的

根据键盘序列导航的顺序,值为 0 、非法值、或者没有 tabindex 值的元素应该放置在 tabindex 值为正值的元素后面。

title

元素呈现给用户的文本信息

常用内容标签

ol

有序列表

ul

无序列表

table

表格,tr代表行, td是行数据,th是标题

  1. <table>
  2. <thead>
  3. <tr>
  4. <th colspan="2">The table header</th>
  5. </tr>
  6. </thead>
  7. <tbody>
  8. <tr>
  9. <td>The table body</td>
  10. <td>with two columns</td>
  11. </tr>
  12. </tbody>
  13. </table>

a

链接

strong em

strong 强调内容,显示加粗
em强调语气,显示斜体

code

等宽方式呈现代码

  1. <p>Regular text. <code>This is code.</code> Regular text.</p>

pre

显示预定义格式
文本中的空白符(比如空格和换行符)都会显示出来