语义 – 跨度的语义价值

前端之家收集整理的这篇文章主要介绍了语义 – 跨度的语义价值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
跨度元素似乎完全像一个div,而是在线级而不是块级.然而,我似乎不能想到跨元素可以提供的任何有益的逻辑划分. @H_404_2@一句话或一句话,如果不包含在句子中,似乎是最小的逻辑部分.忽略CSS,因为CSS仅用于布局而不是语义意义上,跨越提供额外的语义值时,通过剔除一个句子或一串字呢?@H_403_3@ @H_404_2@似乎在所有情况下,其他元素更适合于添加语义值,使跨越一个纯布局元素.这是真的?@H_403_3@

解决方法

Span可以用来添加超出 HTML范围的语义.这可以通过使用识别某些属性的类来完成.例如,如果您正在撰写科幻小说,您可以使用span来识别组合词,因为您可能希望格式化格式不同,或者您可能希望拼写检查器忽略它们:
@H_404_2@Then the wizard called upon the <span class=”wizardword”>gravenwist</span> and bade it attack the approaching army. The <span class=”wizardword”>gavenwist</span> resisted but the wizard’s <span class=”wizardword”>wistwand</span> was too powerful.@H_403_3@
@H_404_2@这可以渲染为@H_403_3@
@H_404_2@Then the wizard called upon the gravenwist and bade it attack the approaching army. The gavenwist resisted but the wizard’s wistwand was too powerful.@H_403_3@
@H_404_2@这种事情的另一个很好的例子是microformats,它允许在HTML内创建任意结构:@H_403_3@
<span class="tel">
 <span class="type">home</span>:
 <span class="value">+1.415.555.1212</span>
</span>
@H_404_2@跨度与div的优点在于,跨度可以出现在几乎所有地方,因为它们是内联内容,而div是块元素,因此它们只能发生在某些其他元素内.@H_403_3@

猜你在找的HTML相关文章