关于span

来源:互联网 发布:游龙网络有出什么游戏 编辑:程序博客网 时间:2024/06/01 15:25

今天上午发现有个网站是这么用<span>的.点击打开链接


我的疑问是为什么不直接用<p>?

后面发现该内容在English版面中就是直接使用<p>.

那么问题来了:

1.什么时候使用<span>最恰当?

Wiki的定义是,当没有其他html元素能够恰当定义文档内容时.可以使用<span>或<div>并使用class,id,lang,或dir属性来进行调用。

<p>,<em>一类的元素能准确体现html文档的语义,而<span>和<div>则既能提升用户体验,又有助于开发者维护。

In HTMLspan and div elements are used to define parts of a document so that they are identifiable when no other HTML element is suitable. While other HTML elements such as p (paragraph), em (emphasis) and so on accurately represent the semantics of the content, the use of span and div leads to better accessibility for readers and easier maintainability for authors. Where no existing HTML element is applicable, span and div can valuably represent parts of a document so that HTML attributes such as classidlang, or dir can be applied.[1][2]


2.语义化的含义和意义

来自百度:语义化的网页的好处,最主要的就是对搜索引擎友好,有了良好的结构和语义你的网页内容自然容易被搜索引擎抓取,你网站的推广便可以省下不少的功夫。
(wiki的话说 makes it easier for web agents such as search engines and other software to ascertain the significance of the text.)
语义 Web 技术有助于利用基于开放标准的技术,从数据、文档内容或应用代码中分离出意义。
wiki还列举了一个反面例子,就是把<i>当成<em>来用.

正确姿势是emphasize顾名思义用于强调,并可利用CSS修改效果.而italic多用于引用来源(citing resources),引用外来语(foreign phrases or loanwords)




0 0
原创粉丝点击