MIP HTML规范

2018-11-07 17:28 更新

头部使用规范

  • 起始标签使用 <!doctype html>

  • html标签必须加上mip标记,即: <html mip>

  • 必须包含 <head>和 <body>标签

  • 必须在head标签中包含字符集声明: <meta charset="utf-8">,字符集统一为utf-8

  • 必须在head标签中包含viewport设置标签: <meta name="viewport" content="width=device-width,minimum-scale=1">,推荐包含initial-scale=1

  • 必须在head标签中包含 < link rel="stylesheet" type="text/css" href="https://mipcache.bdstatic.com/static/mipmain-v1.1.1.css" >

  • 必须在body标签中包含 <script src="https://mipcache.bdstatic.com/static/mipmain-v1.1.2.js" ></script >

  • 必须在head标签中包含 <link rel="canonical" href="http(s)://xxx" >

页面元素使用规范

MIP HTML 禁止使用对页面性能以及安全有较大影响的标签,请将其替换为MIP的特有标签(例如:将img标签替换为mip-img):

标签使用范围备注
img替换为mip-img 
video替换为mip-video 
audio替换为mip-audio 
iframe替换为mip-iframe 
style替换为<style mip-custom>只能在head标签中使用一次
script禁止使用禁止使用script标签, 以下两种情况除外:1)外链mip组件所需js,2)type为 "application/ld+json" 或 "application/json"
svg允许使用 
button允许使用 
link允许使用不允许使用link标签进行样式表的加载
a允许使用不可以href="javascript:",target必须设置为_blank
frame禁止使用 
frameset禁止使用 
object禁止使用 
param禁止使用 
applet禁止使用 
embed禁止使用 
form替换为mip-form内部允许使用input标签
input elements禁止使用包括: input, textareaa, select, option

自定义样式使用规范

出于性能考虑,html 中不允许使用内联style,所有样式只能放到head 的 style 标签里。

  • 正确:
<head>
    <style mip-custom>
        p { color: #00f;}
    </style>
</head>
<body>
    <p>Hello World!</p>
</body>
  • 错误:
<p style="color:#00f;">Hello World!</p>

验证规范

MIP校验工具地址:https://www.mipengine.org/validator/validate

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号