item-6ren">
gpt4 book ai didi

html - 如何为微数据嵌套 <meta> 标签?

转载 作者:行者123 更新时间:2023-12-01 18:09:46 24 4
gpt4 key购买 nike

我有这样的结构:

+ EVENT -> itemtype="http://schema.org/Event
+ Name
+ Date
+ ...
+ LOCATION -> itemtype="http://schema.org/Place
* Name
+ Url
+ ...

我不会在网站上显示所有地点信息,但我想将这些信息用于微数据。所以我想添加这个标签:

<meta itemprop="location" itemscope itemtype="http://schema.org/Place">

工作正常。

但是我如何为nameurllocation添加itemprops?

它不会像这样工作:

<meta itemprop="location" itemscope itemtype="http://schema.org/Place">
<meta itemprop="url" content="https://example-location.com">
<meta itemprop="name" content="exampleLocationName">

最佳答案

大概是这样的。其实不太确定。

<meta itemprop="location" content="" itemscope itemtype="http://schema.org/Place" itemref="place-url place-name">
<link id="place-url" itemprop="url" href="https://example-location.com">
<meta id="place-name" itemprop="name" content="exampleLocationName">
<小时/>

你就不能把丑陋的空东西扔掉吗content

https://www.w3.org/TR/microdata#x7-2-content-models

If a meta element has an itemprop attribute, the name, http-equiv, and charset attributes must be omitted, and the content attribute must be present.

你不能。

为什么 <link>而不是<meta>

因为只有 URL 属性元素可以将绝对 URL 作为其值,并且 <link>一会儿<meta>不是。

来自https://www.w3.org/TR/microdata#x5-4-values-the-content-attribute-element-specific-attributes-and-element-content :

The algorithm to determine the value for a name-value pair is given by applying the first matching case in the following list:

  • If the element also has an itemscope attribute: the value is the item created by the element.
  • If the element has a content attribute: the value is the textContent of the element’s content attribute.

 

The URL property elements are the a, area, audio, embed, iframe, img, link, object, source, track, and video elements.

 

If a property’s value, as defined by the property’s definition, is an absolute URL, the property must be specified using a URL property element.

嵌套怎么样 <meta>标签?

你不能,因为 <meta>是一个 void 元素,它不能有任何子元素。

<小时/>

更好

您考虑过using JSON-LD相反?

关于html - 如何为微数据嵌套 &lt;meta&gt; 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42006735/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com