MIP頁(yè)面會(huì)有嚴(yán)格的規(guī)范校驗(yàn),不允許存在任何校驗(yàn)不通過的問題存在.
MIP校驗(yàn)工具地址:https://www.mipengine.org/validator/validate
本文檔意在幫助開發(fā)者找到校驗(yàn)的內(nèi)容和規(guī)則,快速定位校驗(yàn)不通過的原因
提示 | MANDATORY_TAG_MISSING |
---|---|
錯(cuò)誤說明 | "The mandatory tag '%1' is missing or incorrect." |
錯(cuò)誤說明 | 強(qiáng)制性標(biāo)簽'xxx'缺失或錯(cuò)誤 |
修復(fù)方法 | 添加(或者更正)強(qiáng)制性html標(biāo)簽 |
在MIP HTML中,強(qiáng)制性標(biāo)簽包括:
說明 | 備注 |
---|---|
<!doctype html> | 大小寫均可 |
<html mip> | 強(qiáng)制小寫 |
<head> | 強(qiáng)制小寫 |
<meta charset="utf-8"> | utf-8不區(qū)分大小寫,無(wú)單引號(hào)或者雙引號(hào)限制 |
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> | 強(qiáng)制小寫,無(wú)單引號(hào)或者雙引號(hào)限制 |
< link rel="stylesheet" type="text/css" href="https://mipcache.bdstatic.com/static/mipmain-v1.1.1.css" > | 強(qiáng)制小寫,無(wú)單引號(hào)或者雙引號(hào)限制,v1.1.1會(huì)根據(jù)版本不同而不同 |
<script src="https://mipcache.bdstatic.com/static/mipmain-v1.1.2.js" ></script > | 強(qiáng)制小寫,無(wú)單引號(hào)或者雙引號(hào)限制,v1.1.2會(huì)根據(jù)版本不同而不同 |
<body> | 強(qiáng)制小寫 |
<link rel="canonical" href="http(s)://xxx"> | 強(qiáng)制小寫 |
提示 | DISALLOWED_TAG |
---|---|
錯(cuò)誤說明 | "The tag '%1' is disallowed." |
錯(cuò)誤說明 | 禁止使用'xx'標(biāo)簽 |
修復(fù)方法 | 刪除禁用標(biāo)簽 |
目前mip中標(biāo)簽使用規(guī)則:
禁止使用標(biāo)簽有:
如果有如下標(biāo)簽需要進(jìn)行替換
標(biāo)簽 | 替換后標(biāo)簽 |
---|---|
img | mip-img |
video | mip-video(暫未開放) |
audio | mip-audio(暫未開放) |
其他說明:
<p style="color: #000;">
錯(cuò)提示 | INVALID_ATTR_VALUE |
---|---|
錯(cuò)誤說明 | "The attribute '%1' in tag '%2' is set to the invalid value '%3'." |
錯(cuò)誤說明 | 標(biāo)簽'xx'中的屬性'xx'的屬性值'xx'無(wú)效 |
修復(fù)方法 | 修改為有效屬性值 |
當(dāng)html標(biāo)簽有屬性值不正確的時(shí)候,會(huì)報(bào)這個(gè)錯(cuò)誤。mip中需要注意的有:
a:href屬性不允許使用javascript:協(xié)議,
a:target屬性需要設(shè)置為_blank
mip-img
mip-pix
其他html基本頁(yè)面屬性規(guī)范不變
<a>
標(biāo)簽:<a href="javascript:xxx()"></a>
錯(cuò)<a href="xxx" target="_blank"></a>
對(duì)提示 | INVALID_PROPERTY_VALUE_IN_ATTR_VALUE |
---|---|
錯(cuò)誤說明 | "The property '%1' in attribute '%2' in tag '%3' is set to '%4', which is invalid." |
錯(cuò)誤說明 | 標(biāo)簽'xx'中存在屬性'yy','yy'中存在屬性'zz',屬性'zz'的屬性值'aa'無(wú)效 |
修復(fù)方法 | 更正無(wú)效屬性值 |
可能出現(xiàn)屬性值的無(wú)效值的情況:
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<script type="application/ld+json"></script>
<script type="application/json"></script>
提示 | MANDATORY_ONEOF_ATTR_MISSING |
---|---|
錯(cuò)誤說明 | "The tag '%1' is missing a mandatory attribute - pick one of %2." |
錯(cuò)誤說明 | 標(biāo)簽'xx'的強(qiáng)制性屬性'xx'缺失 |
修復(fù)方法 | 添加正確是屬性 |
mip html中具有強(qiáng)制性屬性的標(biāo)簽及其強(qiáng)制性屬性有:
提示 | WRONG_PARENT_TAG |
---|---|
錯(cuò)誤說明 | "The parent tag of tag '%1' is '%2', but it can only be '%3'." |
錯(cuò)誤說明 | 標(biāo)簽'a'的直接父標(biāo)簽應(yīng)該是'b',而不是'c' |
修復(fù)方法 | 添加所需的父標(biāo)簽 |
有一些標(biāo)簽有制定的直接父標(biāo)簽,如下示例給出了每個(gè)標(biāo)簽必須的直接父標(biāo)簽:
提示 | DISALLOWED_TAG_ANCESTOR |
---|---|
錯(cuò)誤說明 | "The tag '%1' may not appear as a descendant of tag '%2'." |
錯(cuò)誤說明 | 標(biāo)簽'a'不應(yīng)該是標(biāo)簽'b'的子標(biāo)簽 |
修復(fù)方法 | 刪除非法嵌套標(biāo)簽 |
如:
<body>
的子標(biāo)簽寫在了<head>
中提示 | MANDATORY_TAG_ANCESTOR |
---|---|
錯(cuò)誤說明 | "The tag '%1' may only appear as a descendant of tag '%2'." |
錯(cuò)誤說明 | M標(biāo)簽'a'只能是標(biāo)簽'b'的子級(jí)標(biāo)簽 |
修復(fù)方法 | 刪除標(biāo)簽或者給標(biāo)簽添加正確的父級(jí)標(biāo)簽 |
提示 | DUPLICATE_UNIQUE_TAG |
---|---|
錯(cuò)誤說明 | "The tag '%1' appears more than once in the document." |
錯(cuò)誤說明 | 標(biāo)簽'xx'只能出現(xiàn)一次 |
修復(fù)方法 | 刪除多余的標(biāo)簽 |
一份html中,有的標(biāo)簽具有唯一性,也就是說只能出現(xiàn)一次,當(dāng)html中有重復(fù)的唯一標(biāo)簽的時(shí)候,應(yīng)該報(bào)錯(cuò)。
以下是唯一標(biāo)簽列表:
<doctype html>
<html mip>
<head>
<link rel="canonical" href=...>
<link rel="standardhtml" href=...>
<link rel="miphtml" href=...>
<meta charset="utf-8">
<meta viewport>
<style mip-custom>
<body>
更多建議: