Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 Validation in Visual Studio 2010 - script still requires type tag?

I am validating against HTML5 obtained through VS2010 SP1. I was under the impression that this simplification was possible:

<script type="text/javascript" src="foo.js">...</script>

to

<script src="foo.js">...</script>

In attempting this, I found:

<head id="Head1" runat="server">
  <script src="../Scripts/MicrosoftAjax.js"></script>
</head>

yielded this:

Warning 1 Validation (HTML5): Element 'script' is missing required attribute 'type'.

Am I missing something? Is the Visual Studio XHTML5 validation more strict than the HTML5 doc necessitates?

like image 655
Sean Anderson Avatar asked Jun 08 '11 23:06

Sean Anderson


People also ask

How to validate HTML in Visual Studio?

Follow the steps: Launch Visual Studio 2012. Go to Tools > Options menu. When Options configuration screen is displayed, go to Text Editor > HTML > Validation.

How do I add HTML5 to Visual Studio?

Turn it on After installing SP1 you have to tell Visual Studio to start using the HTML5 schema. Go to Tools -> Options, and then select Text Editor -> HTML -> Validation. You should now be able to select HTML5 or XHTML5 as the target schema.


2 Answers

I resolved the issue by manually editing the schema file.

 <xsd:element name="script">
    ...
    <xsd:attribute name="type" vs:readonly="true" use="required">
    ...
  1. Close all instances of Visual Studio 2010
  2. Open a text editor as a user with administrative rights
  3. Open the file html_5.xsd in the VS schemas folder
    <Program Files>\Microsoft Visual Studio 10.0\Common7\Packages\schemas\html
  4. On line 617 (within the xsd:element name="script" tag) remove the use="required" attribute.
  5. Save the file.
  6. Reopen Visual Studio 2010
like image 170
splattne Avatar answered Sep 23 '22 02:09

splattne


Seems like it's been submitted to Connect. The VS validator is being stricter than the HTML5 spec.

like image 24
keyboardP Avatar answered Sep 24 '22 02:09

keyboardP