如何在没有警告的情况下使Visual Studio处理HTML 5标签 [英] How to make Visual Studio Handle HTML 5 Tags without warning

查看:79
本文介绍了如何在没有警告的情况下使Visual Studio处理HTML 5标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有各种html标记(与jquery mobile相关),Visual Studio将其标记为无效属性:例如:

<div data-role="page" id="my_id" data-theme="b" data-position="fixed">

获得其他奖励:

Validation (XHTML 1.0 Transitional): Attribute 'data-role'
is not a valid attribute of element 'div'

您知道,data- *是HTML 5中div的有效属性.

虽然我认为可以通过DTD和xmlns进行验证,但是我不确定如何验证这一点,因此页面的顶部是Visual Studio自动生成的默认值:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

我知道它们只是警告,但是我的经验是,如果您留下许多无效的警告,那么所有有效的警告都会在中间消失.

有没有办法告诉Visual Studio在完全禁用html验证的情况下不显示这些警告?

(如果相关,则为Visual Studio 2010.)

解决方案

您应该安装

Gets amongst others:

Validation (XHTML 1.0 Transitional): Attribute 'data-role'
is not a valid attribute of element 'div'

As you know, data-* are valid attributes of div in HTML 5.

I'm not sure how this is validated, though I think via DTDs and xmlns, so the head of the page is the default auto generated by Visual Studio:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

I know they are only warnings, but my experience is that if you leave lots of warnings that are invalid, then all the warnings that are valid get lost in the middle.

Is there any way to tell Visual Studio that these warnings should not be shown without completely disabling html validation?

(Visual Studio 2010 if it is relevant.)

解决方案

You should install the Web Standards Update and then switch to HTML5 as your default schema:

In addition, you should not use the XHTML 1.0 transitional opening incantation when using HTML 5 attributes. Instead, use the usual HTML5 one:

<!DOCTYPE html>
<html>

这篇关于如何在没有警告的情况下使Visual Studio处理HTML 5标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆