HTML Heading, Paragraph, Text Formatting
Headings 标题
HTML文档一共有从<h1>到<h6>,共6个级别的标题,重要性依次递减。
注意:不要使用heading来实现文本字体的加粗或加大效果。因为搜索引擎使用 heading 来索引网页的结构和内容。
Paragraphs 段落
HTML使用 <p> 元素来定义段落。
HTML Display
在 HTML 代码中写额外的空格或者是换行都不能改变文档的输出结果。
浏览器会删除多余的空格和分段,不论你在同一个元素里代码写了多少个空格(或新段落),都将被记为一个空格。
Line Break
需要在同一个 <p> 里换行可以使用标签 <br> 元素。
HTML <pre> Element
该元素定义了 pre-formatted text, 使用该元素来保留其中 text node 里的空格和分段格式。
Horizontal Rules
<hr> 元素在网页中创建水平横线,可用于分隔内容。
Text Formatting
HTML也定义了一些特别的元素,用来给文本赋予特殊的meaning。
Bold and Strong
The <b> element defines bold text, <strong> element with added semantic “strong” importance.
Italic and Emphasized
The <i> element defines italic text, <em> element defines emphasized text with added semantic importance.
Often <strong> renders as <b>, and <em> renders as <i>. However, there is a difference in the meaning of these tags.
前两者表示希望指定的文本被用户理解为是重要的,而不仅仅是粗/斜体字,尽管目前浏览器让这些元素以粗体或斜体字显示。
If a browser one day wants to make a text highlighted with the strong feature, it might be cursive 草书体 for example and not bold!
HTML Text Formatting Tags
<b>bold text 粗体字<i>can be used to indicate a technical term 技术词汇, a phrase from another language 其他语言的短语, a thought 一个想法, or a ship name 或者是一个名字, etc.<strong>important text<em>emphasized text 强调文本<small>smaller text<mark>new in H5 marked/highlighted text, 高亮或标注文本,IE8及之前不支持<del>definesdeleted(removed) text, 效果同给文本加删除线<u>defines underline (added)text, 文本被渲染with下划线<ins>defines inserted (added)text, 效果同给文本加下划线<sub>appears half a character below the baseline 低于基准线半个字符高度,用于化学式<sup>superscripted text 高于基准线半个字符, 用于脚注:WWW[1]