Web 开发人员版 — 最后更新于 2024年9月12日
本规范未提供描述面包屑导航菜单的机器可读方式。鼓励作者仅使用段落中的一系列链接。可以使用 nav
元素将包含这些段落的区域标记为导航块。
在以下示例中,可以通过两种路径到达当前页面。
< nav >
< p >
< a href = "/" > Main</ a > ▸
< a href = "/products/" > Products</ a > ▸
< a href = "/products/dishwashers/" > Dishwashers</ a > ▸
< a > Second hand</ a >
</ p >
< p >
< a href = "/" > Main</ a > ▸
< a href = "/second-hand/" > Second hand</ a > ▸
< a > Dishwashers</ a >
</ p >
</ nav >
本规范未定义任何专门用于标记应用于一组页面(也称为标签云)的关键字列表的标记。通常,鼓励作者使用 ul
元素以及显式的内联计数来标记此类列表,然后隐藏这些计数,并使用样式表将其转换为表示效果,或者使用 SVG。
这里,三个标签包含在一个简短的标签云中
< style >
. tag-cloud > li > span { display : none ; }
. tag-cloud > li { display : inline ; }
. tag-cloud-1 { font-size : 0.7 em ; }
. tag-cloud-2 { font-size : 0.9 em ; }
. tag-cloud-3 { font-size : 1.1 em ; }
. tag-cloud-4 { font-size : 1.3 em ; }
. tag-cloud-5 { font-size : 1.5 em ; }
@ media speech {
. tag-cloud > li > span { display : inline }
}
</ style >
...
< ul class = "tag-cloud" >
< li class = "tag-cloud-4" >< a title = "28 instances" href = "/t/apple" > apple</ a > < span > (popular)</ span >
< li class = "tag-cloud-2" >< a title = "6 instances" href = "/t/kiwi" > kiwi</ a > < span > (rare)</ span >
< li class = "tag-cloud-5" >< a title = "41 instances" href = "/t/pear" > pear</ a > < span > (very popular)</ span >
</ ul >
每个标签的实际频率使用 title
属性给出。提供了一个 CSS 样式表将标记转换为不同大小的单词云,但对于不支持 CSS 或不是视觉的用户代理,标记包含注释,如“(流行)”或“(稀有)”来按频率对各种标签进行分类,从而使所有用户都能从信息中受益。
使用 ul
元素(而不是 ol
)是因为顺序并不特别重要:虽然列表实际上按字母顺序排序,但如果按标签长度排序,它也会传达相同的信息。
本规范未定义用于标记对话、会议记录、聊天记录、剧本中的对话、即时消息日志以及其他不同参与者轮流进行话语的情况的特定元素。
相反,鼓励作者使用 p
元素和标点符号来标记对话。需要为样式目的标记说话者的作者鼓励使用 span
或 b
。文本包含在 i
元素中的段落可用于标记舞台提示。
此示例使用 Abbot 和 Costello 的著名草图《谁是第一》的摘录来演示这一点
< p > Costello: Look, you gotta first baseman?
< p > Abbott: Certainly.
< p > Costello: Who's playing first?
< p > Abbott: That's right.
< p > Costello becomes exasperated.
< p > Costello: When you pay off the first baseman every month, who gets the money?
< p > Abbott: Every dollar of it.
以下摘录显示了如何使用 data
元素为每一行提供 Unix 时间戳来标记 IM 对话记录。请注意,时间戳采用 time
元素不支持的格式,因此使用 data
元素(即 Unix time_t
时间戳)。如果作者希望使用 time
元素支持的日期和时间格式之一来标记数据,则可以使用该元素代替 data
。这可能是有利的,因为它允许数据分析工具明确地检测时间戳,而无需与页面作者协调。
< p > < data value = "1319898155" > 14:22</ data > < b > egof</ b > I'm not that nerdy, I've only seen 30% of the star trek episodes
< p > < data value = "1319898192" > 14:23</ data > < b > kaj</ b > if you know what percentage of the star trek episodes you have seen, you are inarguably nerdy
< p > < data value = "1319898200" > 14:23</ data > < b > egof</ b > it's unarguably
< p > < data value = "1319898228" > 14:23</ data > < i > * kaj blinks</ i >
< p > < data value = "1319898260" > 14:24</ data > < b > kaj</ b > you are not helping your case
HTML 没有很好的方法来标记图形,因此游戏交互对话的描述更难以标记。此示例显示了一种可能的约定,使用 dl
元素列出对话中每个点的可能回复。另一个需要考虑的选项是以 DOT 文件的形式描述对话,并将结果输出为 SVG 图像以放置在文档中。 [DOT]
< p > Next, you meet a fisher. You can say one of several greetings:
< dl >
< dt > "Hello there!"
< dd >
< p > She responds with "Hello, how may I help you?"; you can respond with:
< dl >
< dt > "I would like to buy a fish."
< dd > < p > She sells you a fish and the conversation finishes.
< dt > "Can I borrow your boat?"
< dd >
< p > She is surprised and asks "What are you offering in return?".
< dl >
< dt > "Five gold." (if you have enough)
< dt > "Ten gold." (if you have enough)
< dt > "Fifteen gold." (if you have enough)
< dd > < p > She lends you her boat. The conversation ends.
< dt > "A fish." (if you have one)
< dt > "A newspaper." (if you have one)
< dt > "A pebble." (if you have one)
< dd > < p > "No thanks", she replies. Your conversation options
at this point are the same as they were after asking to borrow
her boat, minus any options you've suggested before.
</ dl >
</ dd >
</ dl >
</ dd >
< dt > "Vote for me in the next election!"
< dd > < p > She turns away. The conversation finishes.
< dt > "Madam, are you aware that your fish are running away?"
< dd >
< p > She looks at you skeptically and says "Fish cannot run, miss".
< dl >
< dt > "You got me!"
< dd > < p > The fisher sighs and the conversation ends.
< dt > "Only kidding."
< dd > < p > "Good one!" she retorts. Your conversation options at this
point are the same as those following "Hello there!" above.
< dt > "Oh, then what are they doing?"
< dd > < p > She looks at her fish, giving you an opportunity to steal
her boat, which you do. The conversation ends.
</ dl >
</ dd >
</ dl >
在某些游戏中,对话更简单:每个角色仅仅有一组固定的台词。在此示例中,游戏常见问题解答/演练列出了每个角色的一些已知可能回复
< section >
< h1 > Dialogue</ h1 >
< p >< small > Some characters repeat their lines in order each time you interact
with them, others randomly pick from amongst their lines. Those who respond in
order have numbered entries in the lists below.</ small >
< h2 > The Shopkeeper</ h2 >
< ul >
< li > How may I help you?
< li > Fresh apples!
< li > A loaf of bread for madam?
</ ul >
< h2 > The pilot</ h2 >
< p > Before the accident:
< ul >
< li > I'm about to fly out, sorry!
< li > Sorry, I'm just waiting for flight clearance and then I'll be off!
</ ul >
< p > After the accident:
< ol >
< li > I'm about to fly out, sorry!
< li > Ok, I'm not leaving right now, my plane is being cleaned.
< li > Ok, it's not being cleaned, it needs a minor repair first.
< li > Ok, ok, stop bothering me! Truth is, I had a crash.
</ ol >
< h2 > Clan Leader</ h2 >
< p > During the first clan meeting:
< ul >
< li > Hey, have you seen my daughter? I bet she's up to something nefarious again...
< li > Nice weather we're having today, eh?
< li > The name is Bailey, Jeff Bailey. How can I help you today?
< li > A glass of water? Fresh from the well!
</ ul >
< p > After the earthquake:
< ol >
< li > Everyone is safe in the shelter, we just have to put out the fire!
< li > I'll go and tell the fire brigade, you keep hosing it down!
</ ol >
</ section >
HTML 没有专门用于标记脚注的机制。以下是建议的替代方案。
对于简短的内联注释,可以使用 title
属性。
在此示例中,对话的两个部分使用 title
属性用类似脚注的内容进行注释。
< p > < b > Customer</ b > : Hello! I wish to register a complaint. Hello. Miss?
< p > < b > Shopkeeper</ b > : < span title = "Colloquial pronunciation of 'What do you'"
> Watcha</ span > mean, miss?
< p > < b > Customer</ b > : Uh, I'm sorry, I have a cold. I wish to make a complaint.
< p > < b > Shopkeeper</ b > : Sorry, < span title = "This is, of course, a lie." > we're
closing for lunch</ span > .
不幸的是,目前不鼓励依赖 title
属性,因为许多用户代理不会以本规范要求的可访问方式公开该属性(例如,需要使用诸如鼠标的指向设备才能显示工具提示,这排除了仅限键盘的用户和仅限触摸的用户,例如任何拥有现代手机或平板电脑的用户)。
如果使用 title
属性,则可以使用 CSS 来吸引读者对具有该属性的元素的注意。
例如,以下 CSS 在具有 title
属性的元素下方放置一条虚线。
[title] { border-bottom : thin dashed; }
对于较长的注释,应使用 a
元素,指向文档后面某个元素。约定是链接的内容是方括号中的数字。
在此示例中,对话中的脚注链接到对话下方的段落。然后,该段落反过来链接回对话,允许用户返回到脚注的位置。
< p > Announcer: Number 16: The < i > hand</ i > .
< p > Interviewer: Good evening. I have with me in the studio tonight
Mr Norman St John Polevaulter, who for the past few years has been
contradicting people. Mr Polevaulter, why < em > do</ em > you
contradict people?
< p > Norman: I don't. < sup >< a href = "#fn1" id = "r1" > [1]</ a ></ sup >
< p > Interviewer: You told me you did!
...
< section >
< p id = "fn1" >< a href = "#r1" > [1]</ a > This is, naturally, a lie,
but paradoxically if it were true he could not say so without
contradicting the interviewer and thus making it false.</ p >
</ section >
对于旁注,即应用于整个文本部分而不是特定单词或句子的较长注释,应使用 aside
元素。
在此示例中,在对话之后给出了一个侧边栏,为其提供了一些上下文。
< p > < span class = "speaker" > Customer</ span > : I will not buy this record, it is scratched.
< p > < span class = "speaker" > Shopkeeper</ span > : I'm sorry?
< p > < span class = "speaker" > Customer</ span > : I will not buy this record, it is scratched.
< p > < span class = "speaker" > Shopkeeper</ span > : No no no, this's'a tobacconist's.
< aside >
< p > In 1970, the British Empire lay in ruins, and foreign
nationalists frequented the streets — many of them Hungarians
(not the streets — the foreign nationals). Sadly, Alexander
Yalt has been publishing incompetently-written phrase books.
</ aside >
对于图形或表格,可以在相关的 figcaption
或 caption
元素中或周围的散文中包含脚注。
在此示例中,表格的单元格包含在散文中的脚注。使用 figure
元素为表格及其脚注的组合提供一个图例。
< figure >
< figcaption > Table 1. Alternative activities for knights.</ figcaption >
< table >
< tr >
< th > Activity
< th > Location
< th > Cost
< tr >
< td > Dance
< td > Wherever possible
< td > £0< sup >< a href = "#fn1" > 1</ a ></ sup >
< tr >
< td > Routines, chorus scenes< sup >< a href = "#fn2" > 2</ a ></ sup >
< td > Undisclosed
< td > Undisclosed
< tr >
< td > Dining< sup >< a href = "#fn3" > 3</ a ></ sup >
< td > Camelot
< td > Cost of ham, jam, and spam< sup >< a href = "#fn4" > 4</ a ></ sup >
</ table >
< p id = "fn1" > 1. Assumed.</ p >
< p id = "fn2" > 2. Footwork impeccable.</ p >
< p id = "fn3" > 3. Quality described as "well".</ p >
< p id = "fn4" > 4. A lot.</ p >
</ figure >
如果元素是以下之一,则称该元素实际上已禁用
button
元素,其 已禁用input
元素,其 已禁用select
元素,其 已禁用textarea
元素,其 已禁用optgroup
元素,其具有 disabled
属性option
元素,其 已禁用fieldset
元素,其为 禁用的字段集此定义用于确定哪些元素可聚焦以及哪些元素与:enabled
和 :disabled
伪类匹配。