简体   繁体   English

哪个语义HTML标签用于显示旁注和警告?

[英]Which semantic HTML tag for displaying side notes and admonitions?

I am writing an online tutorial with sort of side notes or as they call it "admonitions" similar to those in Django tutorial: https://docs.djangoproject.com/en/dev/intro/tutorial01/ (I mean the the boxes with green a frame and a note icon). 我正在编写一个带有侧面笔记的在线教程,或者他们称之为“admonitions”,类似于Django教程中的那些: https//docs.djangoproject.com/en/dev/intro/tutorial01/ (我的意思是盒子绿色框架和注释图标)。

Which HTML tag I should use to enclose such notes to add a semantic meaning of a note that may be useful to read at a given point of a tutorial, but is not part of the main tutorial flow? 我应该使用哪个HTML标记来附加这些注释,以添加注释的语义含义,这对于在教程的给定点读取可能很有用,但不是主要教程流程的一部分?

Noteworthy, the tag must allow for enclosing block elements. 值得注意的是,标签必须允许封闭块元素。

I believe the accepted answer is not quite correct. 我相信接受的答案并不完全正确。 According to the HTML5 working draft , the <aside> element can be used to mark up side notes in certain, but not all cases: 根据HTML5工作草案<aside>元素可用于在某些情况下标记旁注,但不是所有情况:

  1. <aside> is appropriate if the side note " could be considered separate from the content ", for example background material on Switzerland in a much longer news story, or a pull quote in a longer article. 如果旁注“ 可以被认为与内容分开 ”, <aside>是合适的,例如瑞士的背景资料在更长的新闻报道中,或者在更长的文章中引用拉引号。 (examples from W3C document) (来自W3C文件的例子)
  2. <aside> is not appropriate if the side note is " a parenthetical ". 如果旁注是“ 括号 ”,则<aside>是不合适的。 The W3C gives no examples of what it means. W3C没有提供它的含义的例子。 A narrow interpretation would be anything that is put in parentheses, between commas or between dashes. 狭义的解释可以是括号中,逗号之间或破折号之间的任何内容。

If you want to interpret the W3C spec strictly, not all of the sidenotes in the Django tutorial can be marked up with <aside> . 如果您想严格解释W3C规范,并非Django教程中的所有侧注都可以用<aside>标记。 For example, the note titled " Doesn't match what you see? " could not really be considered separate from the content, since it does not make sense without the content next to it. 例如,标题为“ 与您所看到的不匹配? ”的说明实际上不能与内容分开考虑,因为没有旁边的内容就没有意义。 Arguably, " Where should this code live? " is also not an <aside> , as it mentions "this code", which ties it to the content. 可以说,“ 这段代码应该在哪里? ”也不是<aside> ,因为它提到了“这段代码”,它将内容与内容联系起来。

In my opinion, the W3C definition is unnecessarily confusing and restrictive. 在我看来,W3C的定义是不必要的混淆和限制。 The dictionary definition of aside is "a temporary departure from a main theme or topic", and the spec should just stick to that, rather than introducing subtle distinctions. 旁边的字典定义是“暂时偏离主题或主题”,规范应该坚持这一点,而不是引入微妙的区别。 Of course, there is no reason why you can't use <aside> for all sidenotes, if it makes your code simpler. 当然,没有理由不使用<aside>来表示所有的注释,如果它使你的代码更简单。 Think of it as civil disobedience. 将其视为公民不服从。 :) :)


Relevant quote: 相关报价:

The aside element represents a section of a page that consists of content that is tangentially related to the content around the aside element, and which could be considered separate from that content. aside元素表示页面的一部分,该部分由与旁边元素周围的内容相切的内容组成,并且可以被认为与该内容分开。 Such sections are often represented as sidebars in printed typography. 这些部分通常在印刷字体中表示为侧边栏。

The element can be used for typographical effects like pull quotes or sidebars, for advertising, for groups of nav elements, and for other content that is considered separate from the main content of the page. 该元素可用于印刷效果,如拉引号或侧边栏,广告,导航元素组,以及被认为与页面主要内容分开的其他内容。

Note: It's not appropriate to use the aside element just for parentheticals, since those are part of the main flow of the document. 注意:将旁边元素仅用于括号内是不合适的,因为它们是文档主流的一部分。

In HTML5 (supported by all modern browsers), the tag is aside . 在HTML5中(由所有现代浏览器支持),标签aside

From http://www.whatwg.org/specs/web-apps/current-work/multipage/sections.html#the-aside-element : 来自http://www.whatwg.org/specs/web-apps/current-work/multipage/sections.html#the-aside-element

The aside element represents a section of a page that consists of content that is tangentially related to the content around the aside element, and which could be considered separate from that content. aside元素表示页面的一部分,该部分由与旁边元素周围的内容相切的内容组成,并且可以被认为与该内容分开。 Such sections are often represented as sidebars in printed typography. 这些部分通常在印刷字体中表示为侧边栏。

The element can be used for typographical effects like pull quotes or sidebars, for advertising, for groups of nav elements, and for other content that is considered separate from the main content of the page. 该元素可用于印刷效果,如拉引号或侧边栏,广告,导航元素组,以及被认为与页面主要内容分开的其他内容。

It's not appropriate to use the aside element just for parentheticals, since those are part of the main flow of the document. 将旁边元素仅用于括号内是不合适的,因为它们是文档主流的一部分。

This is a block-level element and enclose anything a block-level element usually can (ie almost anything). 这是一个块级元素,通常可以包含任何块级元素(即几乎任何东西)。 It is essentially a "semantic div". 它本质上是一个“语义div”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM