Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何使用链接文本作为schema.org值中的值?_Html_Metadata_Schema.org_Microdata - Fatal编程技术网

Html 如何使用链接文本作为schema.org值中的值?

Html 如何使用链接文本作为schema.org值中的值?,html,metadata,schema.org,microdata,Html,Metadata,Schema.org,Microdata,我试图用微数据标记一些HTML,但是我的标记有一个问题: 以下是我当前的HTML: <div> <h1> <a href="example.com/1234">The name is here</a> <small>(Some extra info)</small> </h1> Tons more content about the thing </d

我试图用微数据标记一些HTML,但是我的标记有一个问题:

以下是我当前的HTML:

<div>
    <h1>
        <a href="example.com/1234">The name is here</a>
        <small>(Some extra info)</small>
    </h1>
    Tons more content about the thing
</div>

(一些额外信息)
对这件事有更多的满足感
我想做的是描述事物的存在及其名称,并尝试:

<div itemscope itemtype="http://schema.org/Thing">
    <h1>
        <a href="example.com/1234" itemprop="name">The name is here</a>
        <small>(Some extra info)</small>
    </h1>
    Tons more content about the thing
</div>

(一些额外信息)
对这件事有更多的满足感
但这给了我一个不正确的元数据:

<div itemscope itemtype="http://schema.org/Thing">
    <h1 itemprop="name">
        <a href="example.com/1234">The name is here</a>
        <small>(Some extra info)</small>
    </h1>
    Tons more content about the thing
</div>


(一些额外信息)
对这件事有更多的满足感
但这也是不正确的,因为它错误地将
(一些额外信息)
标识为名称的一部分(它不是):


总之,有没有一种方法可以将
itemprop
应用于
链接而不使用URL作为属性值?

微数据没有提供一种方法来表示
元素上的
itemprop
不应生成URL作为值

您必须添加另一个元素

  • 是在微数据中生成字符串值的元素之一(:not
    time
    ,并且不是可以具有
    href
    /
    src
    属性的元素之一),以及

  • 仅包含要作为属性值的内容

在您的示例中,可以添加
span
元素:




Dang,有没有一种方法不包括引入冗余元素,或者您可以提供一个支持这种方法的链接?我原以为是这样的,但我想在文档中读一下,这样我就不会再被咬了。@legostrmtropr:我链接到了显示哪些HTML5元素产生了哪些价值的节目。这是基于Microdata部分的,它指定了一个算法来决定属性的值必须是什么。您的示例是第四种情况:“如果元素是
a
[…]元素[…],则值是绝对URL”。双击它。但是,谢谢你的回答:)现在我知道了。