• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com专业计算机教程网站
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure
您的位置:首页 > 网页设计 >html5 > i、em、b、strong元素的使用详解

i、em、b、strong元素的使用详解

作者:匿名 字体:[增加 减小] 来源:互联网 时间:2018-12-03

本文主要包含strong,详解,元素等相关知识,匿名希望在学习及工作中可以帮助到您
这次给大家带来i、em、b、strong元素的使用详解,使用i、em、b、strong元素的注意事项有哪些,下面就是实战案例,一起来看一下。

前言

为了语义化HTML5增加了不少新标签。其中i、em和b、strong这两组标签是最容易弄混的,不好好去探究一下,还真说不清。这个也是前端面试中经常会问的问题。今天从源头上,也就是从HTML5的文档(https://w3c.github.io/html/textlevel-semantics.html#the-em-element)中来一探究竟!

区别详解

首先,单从显示效果来看,在不额外添加css的情况下,i和em标签包围的文字将会以斜体呈现,b和strong标签包围的文字则会加粗显示。如图

效果如下:

<b>和<i>在创建之初就是简单地表示粗体和斜体样式,但是到了HTML5,为了语义化特性,这两个标签也被赋予了语义,样式倒不那么重要,因为那是css的事情。但上面两组标签语义还是各有侧重,下面依照规范逐一介绍:

i介绍

规范描述:

The i element represents a span of text in an alternate voice or mood, or otherwise offset from the normal prose in a manner indicating a different quality of text, such as a taxonomic designation, a technical term, an idiomatic phrase from another language, transliteration, a thought, or a ship name in Western texts.

译文:

i 元素代表在普通文本中具有不同语态或语气的一段文本,某种程度上表明一段不同特性的文本,比如一个分类学名称,一个技术术语,一个外语习语,一个音译,一个想法,或者西方文本中的一艘船名。

举例:

// 分类学名称
<p>The <i class="taxonomy">Felis silvestris catus</i> is cute.</p>
// 术语
<p>The term <i>prose content</i> is defined above.</p>
// 外语习语
<p>There is a certain <i lang="fr">je ne sais quoi</i> in the air.</p>

大家可以在i标签上应用class来表明用这个元素的意图,这样该特殊样式在以后如需修改时,不需要仔细检查全部文档来更改。在使用i标签时候时,推荐考虑是否应用其他标签更为合适,如用em来突出强调,dfn标签来定义项目实例。

em介绍

规范描述:

The em element represents stress emphasis of its contents.

The placement of stress emphasis changes the meaning of the sentence. The element thus forms an integral part of the content. The precise way in which stress is used in this way depends on the language.

译文:

em 元素代表对其内容的强调。突出强调的位置会改变语句本身的意义。因此,元素构成内容的一个部分。用这种方式表示强调的程度依赖于是何种语言。

举例(类似汉语里面重读某个词表示不同含义):

// 这是一句不带任何强调的句子
<p>Cats are cute animals.</p>
// em 包围 Cats,强调猫是种可爱的动物,而不是狗或者其他动物
<p><em>Cats</em> are cute animals.</p>
// em 包围 are,代表句子所说是事实,来反驳那些说猫不可爱的人
<p>Cats <em>are</em> cute animals.</p>
// em 包围 cute,强调猫是一种可爱的动物,而不是有人说的刻薄、讨厌的动物
<p>Cats are <em>cute</em> animals.</p>
// 这里强调猫是动物,而不是植物
<p>Cats are cute <em>animals</em>.</p>

规范末尾note:

The em element isn’t a generic "italics" element. Sometimes, text is intended to stand out from the rest of the paragraph, as if it was in a different mood or voice. For this, the i element is more appropriate.

The em element also isn’t intended to convey importance; for that purpose, the strong element is more appropriate.

译文:

em不是一个普通的斜体标签。有时为了部分文本由于不同的语态或语气需有别于段落的其他部分,这是i标签更为合适。em标签不是为了表明重要性,如果是出于这个目的,strong标签更为合适。

b介绍

规范描述:

The b element represents a span of text to which attention is being drawn for utilitarian purposes without conveying any extra importance and with no implication of an alternate voice or mood, such as key words in a document abstract, product names in a review, actionable words in interactive text-driven software, or an article lede.

译文:

b 元素代表侧重实用目的而不带有任何额外重要性也不暗示不同语态或语气的一段文本,比如一段文本摘要中的关键词、一段审查中的产品名称、文本驱动软件中的可执行语句或者一篇文章的导语。

举例:

// 下面的 b 元素起到突出关键词的作用,但不具备强调重要性的作用
<p>The <b>frobonitor</b> and <b>barbinator</b> components are fried.</p>
// 下面的 b 元素让被包围的词特殊化
<p>You enter a small room. Your <b>sword</b> glows
brighter. A <b>rat</b> scurries past the corner wall.</p>
// 下面的 b 元素标注了文章的导语
<article>
  <h2>Kittens 'adopted' by pet rabbit</h2>
  <p><b class="lede">Six abandoned kittens have found an
    unexpected new mother figure — a pet rabbit.</b></p>
  <p>Veterinary nurse Melanie Humble took the three-week-old
    kittens to her Aberdeen home.</p>
  ...
</article>

规范建议:

The b element should be used as a last resort when no other element is more appropriate. In particular, headings should use the h1 to h6 elements, stress emphasis should use the em element, importance should be denoted with the strong element, and text marked or highlighted should use the mark element.

就是说当没有其他元素合适时,最后才考虑用b标签。特别是,标题应该使用h1到h6标签,突出对内容的强调用em标签,突出重要紧急用strong标签,文本标记使用mark标签。

strong介绍

规范描述:

The strong element represents strong importance, seriousness, or urgency for its contents.

译文:

strong 元素代表内容的强烈的重要性、严重性或者紧急性。

重要性

<strong> 元素可以被用在标题(heading)、说明(caption)或者段落(paragraph)上,来显示这部分被包围的文字的重要性。

// 章节序号不重要,章节的名字才重要
<h1>Chapter 1: <strong>The Praxis</strong></h1>

严重性

<strong> 元素可以被用来标记警告或者

您可能想查找下面的文章:

  • 通过HTML5规范搞定i、em、b、strong元素的区别
  • i、em、b、strong元素的使用详解

相关文章

  • 2018-12-03为什么把 Script 标签放在 body 结束标签之后 html 结束标签之前?
  • 2018-12-03HTML5实践-在非响应式设计中如何使用ViewPort meta标签的方法介绍
  • 2018-12-03phonegap实现进行本地存储的方法介绍
  • 2018-12-03利用HTML5与jQuery技术创建一个简单的自动表单完成
  • 2017-08-06Html5 audio标签样式的修改
  • 2018-12-03在移动端上,JS如何能知道浏览器已经被切换到后台了?
  • 2018-12-03使用HTML5做个画图板的方法介绍_html5教程技巧
  • 2018-12-03整理HTML5移动端开发的常用触摸事件_html5教程技巧
  • 2017-08-06html5实现的便签特效(实战分享)
  • 2018-12-03具体介绍如何用H5实现触屏版的轮播器

文章分类

  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure

最近更新的内容

    • HTML5 3D衣服摇摆动画特效_html5教程技巧
    • HTML5必读书籍
    • 快速玩转网页样式
    • 几种关于HTML 5 的动态效果制作方法
    • HTML5 Canvas像素处理使用接口介绍_html5教程技巧
    • 做一个表白用的静态网页,有什么好的创意?
    • HTML5和CSS3实例教程总结(推荐)
    • 使用html5 canvas 画时钟代码实例分享_html5教程技巧
    • H5的所有元素及基本语法归纳
    • 有关跨域通信的文章推荐10篇

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有