【发布时间】:2018-05-13 15:49:59
【问题描述】:
如果我有一个 HTML5 组件/WebComponent,它有一个定义 <template> 的 component.html 文件,那么在 component.html 中声明 <!DOCTYPE html> 是否有意义?也就是说,以下哪一项是最佳做法?
<template>
<!-- some html content -->
</template>
或者
<!DOCTYPE html>
<template>
<!-- some html content -->
</template>
【问题讨论】:
-
模板不是 HTML 页面,而只是 HTML 的一小部分。所以不需要 Doctype。您的代码将读取模板并将其插入到由 HTML 页面提供的现有 DOM 中。我假设您已经为该页面提供了 Doctype。
标签: html html-parsing web-component html5-template html-imports