我有这样的结构:
+ 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">
工作正常。
但是我如何为name
、url
、location
添加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 anitemprop
attribute, thename
,http-equiv
, andcharset
attributes must be omitted, and thecontent
attribute must be present.
你不能。
为什么 <link>
而不是<meta>
?
因为只有 URL 属性元素可以将绝对 URL 作为其值,并且 <link>
一会儿<meta>
不是。
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 thetextContent
of the element’scontent
attribute.
The URL property elements are the
a
,area
,audio
,embed
,iframe
,img
,link
,object
,source
,track
, andvideo
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 - 如何为微数据嵌套 <meta> 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42006735/