<b> 与 <strong>、<i> 和 <em> 标签之间有什么区别?
本文将讨论 <b> 与 <strong> 标签、<i> 与 <em> 标签之间的区别,并查看一些使用这些标签的示例。
<b> 和 <strong> 标签
<b> HTML 元素用于吸引读者注意那些内容原本不重要的元素。它会以粗体突出显示一段文本,使用户更容易看到。这是一种时尚宣言。它不传达任何额外的含义。
因此,如果我们只需要增加特定单词、短语或段落的字体粗细以用于演示目的,则应该使用 <b> 标签。
语法
<b> 标签写作 <b>/b>,粗体文本插入在开始和结束标签之间。
<b> --bold text-- </b>
HTML <strong> 标签用于强调文本,传统上浏览器会将文本显示为粗体。它突出了内容的重要性。它可以用来强调严肃性、紧迫性或重要性。它表明了必须如何理解某件事。
<strong> 内的文本标签对搜索引擎具有语义意义,并以特殊语调突出显示。
语法
<strong> --需要强调的内容-- </strong>
这些标签之间的区别在于,<b> 仅在视觉上使文本显示为粗体,而 </strong> 标签还提供语义强调,指示有意义的单词或文本部分。在另一个 </strong> 标签内使用的 </strong> 标签权重更大。
造成这种区别的原因是 HTML 区分语义(有意义的)标签和物理(视觉外观)标签。前者指的是各自区域的含义,而后者仅仅定义了浏览器中的光学显示。
让我们看一下这两个标签的用法示例。
示例
在此示例中,我们将演示 HTML 中 <b> 标签的用法。
<!DOCTYPE html>
<html>
<head>
<title> <b> tag in HTML </title>
<style>
div{
background-color:honeydew;
color:darkolivegreen;
width:350px;
height:70px;
padding:20px;
margin:20px;
font-size:17px;
}
</style>
</head>
<body>
<h3>An example of bold tag</h3>
<div>
<p>
The text below is enclosed within the 'bold' tag<br>
<b>I am just bold text without any significance</b>
</p>
</div>
</body>
</html>
示例
在此示例中,我们将演示 HTML 中 <strong> 标签的用法。
<!DOCTYPE html>
<html>
<head>
<title> <strong> tag in HTML </title>
<style>
div{
background-color:mistyrose;
color:mediumvioletred;
width:420px;
height:70px;
padding:20px;
margin:20px;
font-size:17px;
}
</style>
</head>
<body>
<h3>An example of strong tag</h3>
<div>
<p>
The text below is enclosed within the 'strong' tag<br>
<strong>I am a text of strong importance, unlike plain bold text.<strong>
</p>
</div>
</body>
</html>
< i > 和 < em > 标签
在 HTML 中,<i> 标签用于以斜体显示内容。此标签通常用于显示其他语言的技术术语、短语或关键词。<i> 标签与 <b> 标签类似,用于演示目的。它表示文本中不同语调或语气的部分,或表示不同文本质量的部分。
语法
<i> --contents-- </i>
<em> 标签用于强调其内容。它可以改变句子的含义。此标签内的文本也以斜体显示。<em>元素可以嵌套,每嵌套一层,强调程度越高。
语法
<em> --需要强调的内容-- </em>
这两个标签的主要区别在于,<em> 标签在语义上强调重要的单词或单词部分,而 i 标签只是偏移文本,通常以斜体显示,以显示不同的语气或语态。
让我们看一些示例来说明这两个标签的用法。
示例
在此示例中,我们将演示 HTML 中 <i> 标签的用法。
<!DOCTYPE html>
<html>
<head>
<title> <i> tag in HTML </title>
<style>
div{
background-color:mintcream;
color:teal;
width:320px;
height:70px;
padding:20px;
margin:20px;
font-size:17px;
}
</style>
</head>
<body>
<h3>An example of i tag</h3>
<div>
<p>
In French <i>Je m'appelle</i> means 'my name is'
</p>
</div>
</body>
</html>
示例
在此示例中,我们将演示 HTML 中 <em> 标签的用法。
<!DOCTYPE html>
<html>
<head>
<title> <em> tag in HTML </title>
<style>
div{
background-color:linen;
color:purple;
width:320px;
height:50px;
padding:20px;
margin:20px;
font-size:18px;
}
</style>
</head>
<body>
<h3>An example of em tag</h3>
<div>
<p>
<em>I am the emphasized part</em> of the entire text.
</p>
</div>
</body>
</html>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

