【问题标题】:What element to use for the reverse of <abbr><abbr> 的反面使用什么元素
【发布时间】:2015-09-23 01:09:46
【问题描述】:

如果我希望在文本中而不是在 &lt;abbr&gt; 元素的工具提示中显示完整的含义,是否有一个 HTML 元素可以用来表示“这是首字母缩略词的意思”。

比如我想写下“CSS”的定义,我把

<dt>CSS</dt>
<dd>Short for <mark>Cascading Style Sheets</mark>. This is the name of
    the language that stylesheets are written in.</dd>

我现在滥用mark的地方可以使用什么元素?

PS 你可能会考虑不使用任何标记来回答,但我想让这个名字以斜体突出,所以我确实需要一些东西!

【问题讨论】:

  • &lt;em&gt;&lt;/em&gt; 呢?
  • @JeroenBellemans 不,我不是说强调;那将有不同的含义!例如,当我通过语音合成器运行页面时,我不希望说话者提高声音,好像短语更重要。
  • mark 或简单的span 或实际的i 有什么问题?
  • @dfsq:mark 就像使用荧光笔突出显示文本。您不会在这种情况下突出显示文本。
  • @dfsq mark又有不同的意思了;另外,我必须重置mark 默认具有的样式属性。 span 可以,但我希望有更多语义化的东西。然后是i,但是这个在过去的几十年里被滥用了这么多,现在甚至被滥用(用于显示图标),我真的不想再惩罚它了。

标签: html semantic-markup


【解决方案1】:

很遗憾,HTML 没有专门的元素来表示缩写的扩展形式。

the HTML5 spec on abbr 中的这个示例似乎非常接近您的用例,除了缩写出现在段落中的扩展之后,而不是在包含缩写的 dt 之后的 dd 元素中。该示例演示了使用dfn 元素来标记扩展:

<p>The <dfn id=whatwg>Web Hypertext Application Technology
Working Group</dfn> (<abbr
title="Web Hypertext Application Technology Working Group">WHATWG</abbr>)
is a loose unofficial collaboration of Web browser manufacturers and
interested parties who wish to develop new technologies designed to
allow authors to write and deploy Applications over the World Wide
Web.</p>

基于description of dfn,上面写着(强调我的):

dfn 元素表示术语的定义实例。作为dfn 元素的最近祖先的段落、描述列表组 或部分还必须包含dfn 元素给出的术语的定义。

您应该能够类似地标记您的内容:

<dt><abbr title="Cascading Style Sheets">CSS</abbr></dt>
<dd>Short for <dfn>Cascading Style Sheets</dfn>. This is the name of
    the language that stylesheets are written in.</dd>

但是,我不确定 dfn 是否适合出现在 dd 中而不是其关联的 dt 中,即使在同一个 dl 中也是如此。如果这让您感到困扰,那么无需求助于span 的下一个最接近的选择是i

<dt><abbr title="Cascading Style Sheets">CSS</abbr></dt>
<dd>Short for <i>Cascading Style Sheets</i>. This is the name of
    the language that stylesheets are written in.</dd>

(我可能会将dfn 添加为dt 的子代和abbr 的父代)

【讨论】:

  • 好一个;我可能最终会使用它。遗憾的是 dfn 没有属性 for (如标签)。该页面确实说以这种方式使用title,但标题仍然是一个工具提示。哦,好吧。
  • @Mr Lister:确实,这很可惜。
【解决方案2】:

随便用

<i></i> or </em></em>

或使用带有数据属性标签的跨度,例如

<dt>CSS</dt>
<dd>Short for <span data-acronym>Cascading Style Sheets</mark>. This...</dd>

<dt>CSS</dt>
<dd>Short for <span data-acronym="CSS">Cascading Style Sheets</mark>. This..</dd>

如果这是首字母缩略词,您还可以删除“Short for”并只保留

<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>

然后是另一个条目

<dt>Cascading Style Sheets</dt>
<dd>The language format that web stylesheets are written in.</dd>

【讨论】:

  • 这不是只是的首字母缩略词列表。这是一个我想使用全名的问题,我希望标记显示这是全名。
  • &lt;dt&gt;&lt;dd&gt; 是否需要在 &lt;dl&gt;(定义列表)内?
  • @William Turrell:他们这样做了——我假设为简洁起见省略了 dl。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-01-02
  • 1970-01-01
  • 1970-01-01
  • 2019-12-14
  • 2017-11-20
  • 2021-06-04
  • 1970-01-01
相关资源
最近更新 更多