标签标签语义 [英] Label Tag semantics

查看:126
本文介绍了标签标签语义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读,我一般使用跨越或强大来形容文本标签。这对于最佳实践是否正确?它似乎也是一种语义方式,但为什么它仅限于表单元素?



如果我想显示信息如下:

 名称:FOo Bar 
年龄:27
重量:151 kg

$ b

etc?

名称,年龄和体重都可以用标签来描述,重新描述不是输入标签,它在语义上不正确(至少对于html和w3c)。我通常使用

 < span class =label>或< span class =description>或< span class =person-detail> etc 

但通常还应该有一个不属于输入字段的标签标签。因为这可能有点主观,所以我不介意把它变成一个社区wiki或者其他东西。

你应该使用< 定义列表 dl dt dd ):

 < DL> 

< dt>名称< / dt>
< dd> FOo Bar< / dd>

< dt>年龄< / dt>
< dd> 27< / dd>

< dt>重量< / dt>
dd> 151公斤< / dd>

< / dl>

该规格说明可用于



术语和定义,元数据主题和值,问题和答案或任何其他名称 - 值数据组。 b $ b




我认为(用 th )也可以使用 。但我只会在比较几个人时才使用它,而不仅仅列出一个人的数据。


I've read this and I GENERALLY use spans or strongs to describe "text-labels". Is this true for best practices? It seems is also a semantic way but why is it limited to just form elements?

What if I wanted to display information as this:

Name: FOo Bar
Age: 27
Weight: 151 kg

etc?

name, age, and weight can all be described as labels, but since the items they're describing aren't input tags, it isn't semantically correct(for html and w3c at least). I usually use

<span class="label"> or <span class="description"> or <span class="person-detail"> etc

but generally there should also be a tag for labels that don't pertain to input fields. As this might be a bit subjective I don't mind this turning into a community wiki or something

解决方案

You should use a definition list (dl with dt and dd):

<dl>

 <dt>Name</dt>
 <dd>FOo Bar</dd>

 <dt>Age</dt>
 <dd>27</dd>

 <dt>Weight</dt>
 <dd>151 kg</dd>

</dl>

The spec states that it could be used for

terms and definitions, metadata topics and values, questions and answers, or any other groups of name-value data.


I think a table (with th) could be used, too. But I would only use it when I want to compare several people, not just listing the data of one person.

这篇关于标签标签语义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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