什么是强调句子或部分的正确HTML标签? [英] What is the correct HTML tag to emphasize a sentence or a section?

查看:87
本文介绍了什么是强调句子或部分的正确HTML标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到我在整个HTML中使用 blockquote 来强调我的学生必须学习的段落 - 这显然是错误的,因为 blockquote 用于指定从其他来源引用的部分。



在我的情况(数学)中,段落定义(s)或描述一个字,并应该在视觉上突出。



经过一番研究,我发现 em 标记其中标记有压力的文本重点,但是,它似乎是为单个单词或一组单词设计的,但不适用于段落。



所以问题是:什么是正确的HTML标记以强调完整的句子或部分(几段)?

dfn 元素



如果内容很重要因为它sa定义(并且所有定义在文档中都很重要),您可以使用 dfn 元素,并相应地设置父元素的样式。



< < dfn>字词< / dfn>< / p>的定义< d c>< / p><

最近的祖先 p (或 li 部分,或者 dl 中的术语描述组, )必须定义术语。



因此,如果您有多个段落(如下例所示),那些没有 dfn 后代在语义上与术语/定义没有关联。


$ b

 < div class = 定义 > 
< p>关于术语< / p>的段落<! - 语义上不是定义的一部分 - > < dfn>术语< / dfn>< / p>的< b> b< p>定义
< p>有关术语< / p>的另一段落<! - 语义上不是定义的一部分 - >
< / div>

如果定义由多个段落组成,您可以使用 section dl 来表示所有这些段落都包含定义,但两种替代方式都不总是合适的。



strong 元素



如果内容对其他原因很重要(例如,并非每个定义都很重要,或定义以外的内容也可能很重要),则可以使用 strong 元素。它表达了对其内容强烈的重要性,严肃性或紧迫性。



甚至可以通过使用更多的 strong 元素来表达相对的重要性水平:

 < p>< strong>重要部分的句子< / strong>< / p> 

< p>句子加上< strong>< strong>非常重要的部分< / strong>< / strong>< / p>

< p>< strong>重要句子包含< strong>特别重要的部分< / strong>< / strong>< / p>

由于 strong 元素只能包含短语内容,您不能用一个 strong 元素标记多个段落。






如果内容对其他原因很重要,但恰巧包含一个定义, dfn strong <当然,应该合并code>。即使每个定义都很重要,但您仍然可以使用 strong 来传达定义在本文档中的重要性,或者表达它们的相对重要性。


I realized that I was using blockquote throughout my HTML to emphasize paragraphs that have to be learned by my students – which is obviously wrong, since the blockquote is meant to specify a section that is quoted from another source.

In my case (mathematics), the paragraph(s) define(s) or describe(s) a word and should stand out visually.

After some research, I found the em tag which "marks text that has stress emphasis", however, it seems to be designed for single words or a group of words, but not for paragraphs.

So the question is: What is the correct HTML tag to emphasize a complete sentence or a section (several paragraphs)?

解决方案

dfn element

If the content is important because it’s a definition (and all definitions are important in your document), you can use the dfn element and style the parent element accordingly.

<p class="definition">definition of the <dfn>term</dfn></p>

The nearest ancestor p (or li, or section, or term-description group in a dl) has to define the term.

So if you have multiple paragraphs (like in the next example), the paragraphs without the dfn descendant are not semantically connected to the term/definition.

<div class="definition">
  <p>paragraph about the term</p> <!-- semantically not part of the definition -->
  <p>definition of the <dfn>term</dfn></p>
  <p>another paragraph about the term</p> <!-- semantically not part of the definition -->
</div>

If the definition consists of multiple paragraphs, you can either use section or dl to convey that all these paragraphs contain the definition, but both alternatives aren’t always suitable.

strong element

If the content is important for other reasons (e.g., not every definition is important, or things other than definitions can be important, too), you can use the strong element. It conveys

strong importance, seriousness, or urgency for its contents.

You can even convey the relative level of importance by using more strong elements:

<p>sentence with an <strong>important part</strong></p>

<p>sentence with a <strong><strong>very important part</strong></strong></p>

<p><strong>important sentence with an <strong>especially important part</strong></strong></p>

As the strong element can only contain phrasing content, you can’t mark multiple paragraphs with one strong element.


If the content is important for other reasons, but happens to contain a definition, dfn and strong should be combined, of course. And even if every definition is important, you may still use strong in addition, either to convey that definitions are important in this document, or to convey their relative importance.

这篇关于什么是强调句子或部分的正确HTML标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆