Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Visual Studio Handle HTML 5 Tags without warning

Tags:

I have various html tags (related to jquery mobile) that Visual Studio is flagging as not valid attributes: For exmaple:

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

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.)

like image 763
Fred Thomas Avatar asked Jun 22 '11 22:06

Fred Thomas


People also ask

Does Visual Studio support HTML5?

The conclusion is that with Visual Studio today, you can build HTML5 and CSS3 web applications on top of ASP.NET, and with SP1 we are making it a lot easier for you.


1 Answers

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

The settings dialog for changing 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> 
like image 159
Domenic Avatar answered Nov 25 '22 05:11

Domenic