首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用'meta‘元素而不是用CSS隐藏元素?

使用'meta‘元素而不是用CSS隐藏元素?
EN

Stack Overflow用户
提问于 2017-10-27 14:41:43
回答 1查看 179关注 0票数 1

我为博客文章做了一个Schema.org标记。我不确定将<meta>与其他标记组合在一起,将<meta>放在<div>中,甚至将<meta>放在<head>之外是不是正确的方法

代码语言:javascript
复制
<article itemprop="mainEntity" itemscope="" itemtype="https://schema.org/BlogPosting">
<meta itemprop="mainEntityOfPage" itemscope="" itemtype="http://schema.org/WebPage">
<header class="entry-header">
    <h1 class="entry-title" itemprop="headline">Article Title</h1>
    <time itemprop="datePublished" datetime="2017-10-23T11:40:36+00:00" content="2017-10-23T11:40:36+00:00" class="date">
        October 23rd, 2017
    </time>
    <time class="modified" itemprop="dateModified" datetime="2017-10-23T11:49:15+00:00" content="2017-10-23T11:49:15+00:00">
        October 23rd, 2017
    </time>
    <div itemprop="author" itemscope="" itemtype="https://schema.org/Person">
        <meta itemprop="image" content="http://example.com/images/nick.jpg">
        <meta itemprop="name" content="nick">
        <meta itemprop="url" content="http://example.com/authors/nick">
    </div>
    <div itemprop="publisher" itemscope="" itemtype="https://schema.org/Organization">
        <div itemprop="logo" itemscope="" itemtype="https://schema.org/ImageObject">
          <meta itemprop="image" src="http://example.com/logo.png">
          <meta itemprop="url" content="http://example.com">
          <meta itemprop="width" content="300">
          <meta itemprop="height" content="270">
        </div>
        <meta itemprop="name" content="Publicher Name">
    </div>

    <meta itemprop="image" content="http://example.com/uploads/2017/10/Article-title.jpg">
</header>

<div class="entry-content jpibfi_container" itemprop="text">

</div>

</article>

这种结合的原因很简单。我只是不需要向用户显示一些数据,但我需要向SE显示这些数据,我知道用display:none隐藏非样式元素不是一种好方法。

EN

回答 1

Stack Overflow用户

发布于 2017-10-27 15:15:43

是的,对于不可见的数据,meta元素是正确的选择。但是,如果值是URL,则使用must use a link element而不是meta元素。

meta元素的问题:

  • 这是无效的,因为需要content属性:

This answer describes alternatives for mainEntityOfPage.

  • 这是无效的,因为meta不能有src属性:

但如上所述,无论如何都必须使用link元素(具有href属性)。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46968958

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档