客户端脚本生成验证的无效HTML
client side scripts producing non-valid HTML that validates
我注意到使用JavaScript可以生成带有不匹配标记的HTML,这些标记仍然通过w3验证器。例如
<script type="text/javascript>
document.write("<h4>This is large text<h2></h4> This is small text")
</script>
具有未测试的</h4>
并且没有关闭的<h2>
,但是文档仍然作为HTML5(或其他)传递。这可能是关于浏览器兼容性的问题吗?为什么没有检测到?
w3验证器不执行Javascript,也不应该执行。它只检查您明确提供给它的代码。