html - 为什么 Google 建议在 Body 中使用 META TAGS?
问题描述
我正在为 Google 的 Sitelink Searchbox 搜索微数据。所以我在谷歌网站上找到了一个页面。
这是微数据代码 -
<div itemscope itemtype="https://schema.org/WebSite">
<meta itemprop="url" content="https://www.example.com/"/>
<form itemprop="potentialAction" itemscope itemtype="https://schema.org/SearchAction">
<meta itemprop="target" content="https://query.example.com/search?q={search_term_string}"/>
<input itemprop="query-input" type="text" name="search_term_string" required/>
<input type="submit"/>
</form>
</div>
网址 - > https://developers.google.com/search/docs/advanced/structured-data/sitelinks-searchbox
解决方案
一些元标记被允许在文档主体内部<div>
和标记内部。<form>
请参阅<meta>
:元数据元素 - HTML:超文本标记语言 | MDN说:
允许的父母
- ...
<meta itemprop>
: 任何接受元数据内容或流内容的元素。
<div>
在关于流内容的页面中,允许流内容的<form>
元素包括<body>
.
因此,虽然许多元标记只属于<head>
,但当元标记具有时itemprop
,它可以进入<body>
(或<head>
)。
推荐阅读
- r - 具有计数自变量的连续因变量的回归模型
- c# - 如何绕过 Asp.net 控件验证仅针对按钮单击的少数控件?
- java - 使用 Spring Boot 进行客户端证书身份验证
- php - 如何在php中根据所属组名迭代数据并显示
- r - 当我展开绘图时,为什么我的地图绘图保持相同的大小(而不是相应地调整大小)?
- html - Bootstrap CSS - 在网格容器中的一行上显示文本
- java - 如果一个类包含一个具有 system.out.println(); 的匿名块;
- statistics - 对和方差法的误解
- excel - 如果它们具有相同的参数,vba如何不计算行(或只计算一次)
- python - 如何将输出打印到 csv 文件?