简体   繁体   English

的目的是什么 <figure> 元件?

[英]What is the purpose of the <figure> element?

I have been trying to understand the <figure> element; 我一直在试图理解<figure>元素; take a look at this from w3.org : w3.org看一下:

Self-contained in this context does not necessarily mean independent. 在这种情况下,自包含不一定意味着独立。 For example,each sentence in a paragraph is self-contained; 例如,段落中的每个句子都是独立的; an image that is part of a sentence would be inappropriate for figure, but an entire sentence made of images would be fitting. 作为句子一部分的图像不适合用于图形,但由图像构成的整个句子将很合适。

How can an image can be part of a sentence? 图片如何成为句子的一部分? What is this talking about? 这是在说什么 I have read many explanations, but yet I don't understand why I would want to use this element. 我已经阅读了许多说明,但是我仍然不明白为什么要使用此元素。 What is the purpose of this tag? 这个标签的目的是什么?

According to MDN : 根据MDN

Usually a <figure> is an image, illustration, diagram, code snippet, etc., that is referenced in the main flow of a document, but that can be moved to another part of the document or to an appendix without affecting the main flow. 通常, <figure>是图像,插图,图表,代码段等,在文档的主要流程中引用,但是可以移动到文档的另一部分或附录中而不会影响主要流程。

An example of this (based on one from that same MDN link) might be a code snippet that prints the parts of the browser's navigator in an article about that attribute. 一个示例(基于来自同一MDN链接的示例)可能是一个代码段,该代码段在有关该属性的文章中打印了浏览器导航器的各个部分。 You don't need to know the exact code to print that information to understand what is in the navigator , but it can aid the reader's understanding. 您不需要知道确切的代码即可打印该信息以了解navigator器中的内容,但是它可以帮助读者理解。

Additionally, the <figure> tag allows use of the <figcaption> tag as a child, which is a convenient and accessible way to caption images. 此外, <figure>标记允许将<figcaption>标记作为子代使用,这是对字幕图像进行方便且可访问的方式。

HTML5 semantic tags are cryptic for everyone. HTML5语义标签对每个人都是神秘的。 Since the concepts are kept abstract and scientific in purpose, I will use a bunch of over-simplification to make it understandable, in spite of HTML5 gurus telling me how wrong I am. 由于概念是出于抽象和科学目的,因此尽管HTML5专家告诉我我有多错误,但我还是会过分简化以使其易于理解。

Remember that semantic tags are created to be read by computers , not humans. 请记住,语义标签是由计算机而不是人类读取的。 They exist so that google's scripts (and everyone's scripts, but mainly google and hacker bots) can quickly search for figures and index them. 它们的存在是为了使Google的脚本(以及每个人的脚本,但主要是Google和黑客机器人)可以快速搜索数字并将它们编入索引。 To understand semantic tags, think like a script, not as a human. 要理解语义标签,请像脚本一样思考,而不要像人类一样思考。

"If I was a bot programmed by a hacker, how would I mine figures when crawling my website?" “如果我是一个由黑客编程的机器人,那么在爬网时如何挖掘人物?”

If we code a script that looks for IMG tags it will end up gathering a bunch of garbage (ie icons). 如果我们编写一个查找IMG标签的脚本,它将最终收集大量垃圾(即图标)。 What we're interested in is real content, that's what " self-contained content " means: you cut & paste this element from your website into my gallery of mined images in your HTML, and it's useful. 我们感兴趣的是真实内容,这就是“ 自包含内容 ”的意思:您将网站中的此元素剪切并粘贴到HTML中的我的采矿图像库中,这很有用。

Garbage: icons, decorative images, images created by javascript plugins to prettify things, smileys, etc. 垃圾:图标,装饰性图像,由JavaScript插件创建的用于美化事物的图像,笑脸等。

Good finds: charts, photos, diagrams, maps, drawings, etc. 很好的发现:图表,照片,图表,地图,工程图等。

The " Good finds " make sense even if you steal them from your webpage with no context whatsoever, except things like the accompanying "caption" tag. 即使您在没有上下文的情况下从网页上窃取了这些内容,“ 好发现 ”还是有意义的,除了附带的“标题”标记之类的东西。 These tags allow crawlers to associate your images with text tags, making categorization easier So you don't want to miss this content . 这些标签允许抓取工具将您的图片与文本标签相关联,从而使分类更加容易, 因此您不想错过此内容

So we're interested in the figure caption, title, subtitle, whatever, and the figure should wrap all of this. 因此,我们对图形标题,标题,副标题等感兴趣,图形应将所有这些内容包装起来。 The figure tag is not limited to images; Figure标签不限于图像; it can contain text, video, audio, code blocks, anything as long as it's part of that "entity" in your document. 它可以包含文本,视频,音频,代码块以及任何内容,只要它是文档中该“实体”的一部分即可。 So the following is a single figure: 所以下面是一个数字:

图例

Now, in documents like scientific papers you will often find stuff like this: 现在,在诸如科学论文之类的文档中,您通常会发现以下内容:

动物的图片

Although each image makes sense by itself, they make more sense as a group as they are connected by some kind of relationship; 尽管每个图像本身都是有意义的,但是由于它们之间通过某种关系联系在一起,它们作为一个整体更有意义。 sometimes even the order matters (ie series of steps, or photos of states something goes through). 有时甚至订单也很重要(例如,一系列步骤或经历过的状态照片)。 That's a " sentence of figures " and you want to mine them together or you'll lose valuable information. 那是“ 数字句子 ”,您想要将它们一起挖掘,否则您将丢失有价值的信息。

Our mining algorithm would have to understand your website's content with some kind of natural-language-processing AI, or it could just gather the FIGURE tags you provide for it. 我们的挖掘算法必须使用某种自然语言处理AI来了解您网站的内容,或者仅收集您为其提供的Figures标签。 The later is good semantics. 后者是好的语义。

Summarizing, imagine you're the Google AI algorithm mining figures in your code. 总结一下,假设您是Google AI算法在代码中挖掘人物。 Write your figure tags to make this script's job easy. 编写图形标签以简化此脚本的工作。

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

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