开发者

Is it possible to have <DOCTYPE> inside <script>?

Is it possible to have <DOCTYPE> definition inside <script> tag in an HTML page?

I get an error that A DOCTYPE is not allowed in content .

Coul开发者_StackOverflow中文版d someone tell me if I should be getting any such error for that?


Your doctype should be at the top of your document. Why do you want to put it anywhere else?


The way you're doing it (with <script type="text/plain">) is fairly dangerous, but whatever you want to accomplish there can be fixed with CDATA:

<script type="text/plain"><![CDATA[
(Your document)
]]></script>


Keep in mind doctype is a browser instruction, not actual html. Therefore having it anywhere but the top is a bit odd, but more importantly it won't do anything.


Your question forces me to assume that you better understanding of what a doctype is, this link might help: http://www.w3.org/QA/Tips/Doctype

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜