短语标记已针对特定目的进行了解除标记,但它们的显示方式与其他基本标记类似,如< b>,< i>,< pre> 和< tt> ,您已在前一章中看到过.本章将引导您完成所有重要的短语标签,让我们一个接一个地看到它们.
出现在< em> ...</em> 元素显示为强调文字.
<!DOCTYPE html> <html> <head> <title>Emphasized Text Example</title> </head> <body> <p>The following word uses an <em>emphasized</em> typeface.</p> </body> </html>
带有<mark> ... </ mark>元素的所有内容均显示为带有黄色墨水的标记。
<!DOCTYPE html> <html> <head> <title>Marked Text Example</title> </head> <body> <p>The following word has been <mark>marked</mark> with yellow</p> </body> </html>
<strong> ... </ strong>元素中出现的所有内容均显示为重要文本。
<!DOCTYPE html> <html> <head> <title>Strong Text Example</title> </head> <body> <p>The following word uses a <strong>strong</strong> typeface.</p> </body> </html>
您可以通过将文本放在<abbr>并关闭</ abbr>标记内来对其进行缩写。 如果存在,则title属性必须包含此完整描述,而不能包含其他任何内容。
<!DOCTYPE html> <html> <head> <title>Text Abbreviation</title> </head> <body> <p>My best friend's name is <abbr title = "Abhishek">Abhy</abbr>.</p> </body> </html>
<acronym>元素允许您指出<acronym>和</ acronym>标记之间的文本是首字母缩写词。
当前,主要的浏览器不会更改<acronym>元素内容的外观。
<!DOCTYPE html> <html> <head> <title>Acronym Example</title> </head> <body> <p>This chapter covers marking up text in <acronym>XHTML</acronym>.</p> </body> </html>
<bdo> ... </ bdo>元素表示双向替代,用于替代当前文本方向。
<!DOCTYPE html> <html> <head> <title>Text Direction Example</title> </head> <body> <p>This text will go left to right.</p> <p><bdo dir = "rtl">This text will go right to left.</bdo></p> </body> </html>
<dfn> ... </ dfn>元素(或HTML Definition Element)允许您指定要引入一个特殊术语。 它的用法类似于段落中间的斜体字。
通常,第一次引入关键术语时会使用<dfn>元素。 最新的浏览器以斜体字体显示<dfn>元素的内容。
<!DOCTYPE html> <html> <head> <title>Special Terms Example</title> </head> <body> <p>The following word is a <dfn>special</dfn> term.</p> </body> </html>
This will produce the following result −
当您想引用其他来源的文章时,应将其放在<blockquote> ... </ blockquote>标记之间。
<blockquote>元素内的文本通常从周围文本的左右边缘缩进,有时使用斜体字体。
<!DOCTYPE html> <html> <head> <title>Blockquote Example</title> </head> <body> <p>The following description of XHTML is taken from the W3C Web site:</p> <blockquote>XHTML 1.0 is the W3C's first Recommendation for XHTML,following on from earlier work on HTML 4.01, HTML 4.0, HTML 3.2 and HTML 2.0.</blockquote> </body> </html>
<q> ... </ q>元素用于在句子中添加双引号的情况。
<!DOCTYPE html> <html> <head> <title>Double Quote Example</title> </head> <body> <p>Amit is in Spain, <q>I think I am wrong</q>.</p> </body> </html>
如果您引用的是文字,则可以指明将其放置在<cite>标记和</ cite>标记之间的来源
正如您在印刷出版物中所期望的那样,默认情况下,<cite>元素的内容以斜体显示。
<!DOCTYPE html> <html> <head> <title>Citations Example</title> </head> <body> <p>This HTML tutorial is derived from <cite>W3 Standard for HTML</cite>.</p> </body> </html>
出现在网页上的任何编程代码都应放在<code> ... </ code>标记内。 通常,<code>元素的内容以等宽字体显示,就像大多数编程书籍中的代码一样。
<!DOCTYPE html> <html> <head> <title>Computer Code Example</title> </head> <body> <p>Regular text. <code>This is code.</code> Regular text.</p> </body> </html>
在谈论计算机时,如果要告诉读者输入一些文本,可以使用<kbd> ... </ kbd>元素指示应键入的内容,如本例所示。
<!DOCTYPE html> <html> <head> <title>Keyboard Text Example</title> </head> <body> <p>Regular text. <kbd>This is inside kbd element</kbd> Regular text.</p> </body> </html>
该元素通常与<pre>和<code>元素结合使用,以指示该元素的内容是变量。
<!DOCTYPE html> <html> <head> <title>Variable Text Example</title> </head> <body> <p><code>document.write("<var>user-name</var>")</code></p> </body> </html>
<samp> ... </ samp>元素指示程序和脚本等的示例输出。同样,它主要在记录编程或编码概念时使用。
<!DOCTYPE html> <html> <head> <title>Program Output Example</title> </head> <body> <p>Result produced by the program is <samp>Hello World!</samp></p> </body> </html>
<address> ... </ address>元素用于包含任何地址。
<!DOCTYPE html> <html> <head> <title>Address Example</title> </head> <body> <address>388A, Road No 22, Jubilee Hills - Hyderabad</address> </body> </html>