HTML5 (XHTML5) Validation Schema and Intellisense for Visual Studio 2008

July 21, 2009 | .NET | 18 Comments

I’ve been playing around with HTML5 (nice intro at Smashing Magazine) for a side project, and I wanted Visual Studio 2008 to stop telling me the new elements were not valid. So I created a new Validation Schema for Visual Studio 2008 that implements much of the HTML5 spec. I found some hints on how to do this in Visual Studio 2005 and went from there. Here’s a pic of it in action giving you the attributes of of the new <source> tag under a new <video> tag:

Readme.txt

  • There is a lot of confusion about HTML, XHTML, and mime-types. I’ve chose to go with a stricter XML-like syntax of closed tags and quoted attributes, rather than the looser HTML, so I called it “XHTML 5″ although that doesn’t really make it offically XHTML 5 until you do the rest of the research, work, and fun.
  • This is not a 100% perfect implementation. There are bound to be different interpretations of what’s “correct” HTML5 and you have until 2022 to get it right, so please don’t worry about it too much.

What’s Finished

  • All the new elements in HTML5 have been added in the follow groupings
    • structure: article, aside, footer, header, nav, section
    • media: audio, video, source
    • other: bb, canvas, command, datagrid, datalist, details, dialog, eventsource, figure, hgroup, keygen, mark, menu, meter, output, progress, time
  • When new elements have custom attributes (such as height and width for video, I’ve tried to add those)
  • I’ve also changed a few things like not requiring the type attribute on script blocks and allowing meta tags to have a charset attribute
  • I’ve begun adding HTML5 events (ondrag, onplay, etc.) but have not completed all of them
  • I am not sure how to add HTML5 style data- attributes, so those won’t validate yet.

How to Use it

  1. Download XHTML Validation Schema for Visual Studio 2008
  2. Save it to C:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\schemas\html\
  3. Add the following to the Registry:
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Packages\{1B437D20-F8FE-11D2-A6AE-00104BCC7269}\Schemas\Schema 23]
    “Friendly Name”=”XHTML 5″
    “URI”=”http://schemas.microsoft.com/intellisense/xhtml5
    “File”=”html\\xhtml5.xsd”

    Note that you might need to change “Schema 23″ to something else if you already have other non-default schemas installed. You just need to use the next available number in the list.

I hope you find it helpful. Please let me know if you end up using it and feel free to suggest updates or corrections.

18 Responses to “HTML5 (XHTML5) Validation Schema and Intellisense for Visual Studio 2008”

  1. Davin says:

    Thanks a ton sir for this. I love it.

  2. John, are you planning to set Spanish Bible Version like (La Biblia De Las Américas-LBLA) in this web app?

  3. John Dyer says:

    I would love to, but I’m haven’t yet secured rights to a Spanish text that has lexical information. If you know of one, let me know!

  4. Weston Ruter says:

    But alas, if only there was an equivalent for Komodo Edit. Maybe I’ll put one together. Thanks for the inspiration!

  5. Dean says:

    You should actually have a read of the HTML5 spec before you do this sort of thing. The fact that you’re using quoted attributes and a "/" in your void elements does not mean you’re using XHTML5 as these are aloud both in HTML5 and XHTML5. The primary difference between HTML5 and XHTML5 is that HTML5 is processed by a HTML parser, and XHTML5 is processed by a XML parser. It’s not like HTML4/XHTML1 were the differences were only in syntax (according to the W3C validator etc).

  6. John Dyer says:

    Awesomeness.

    As I said, I realize there is plenty of confusion/debate around the specs, syntax, and mimetype issues. This is just a way to get the HTML5 tags to show up in Visual Studio and go with the stricter XML-like syntax of closed tags than the looser HTML style. After that, you have to make the other decisions.

  7. I’ll try to search and let you know. Thanks!

  8. Thanks John,

    The "Reina Valera 1960" is by far the most used version in spanish.

    May the Lord bless you. Keep in the good job!

  9. Can�t believe that I�m the first one to digg this? Anyway, I did. Thanks for this awesome information.

  10. john says:

    Kust downloaded this, works great

    Thanks

    Jogn

  11. Makes a lot of sense and thanks for explaining that! I finally get it :o)

  12. Thanks, you cleared up some things for me.

  13. Vivian says:

    Hi John,

    First of all, thank you for your hard work!

    I followed the steps you mentioned.
    One problem I encountered was I could not find the Packages folder inside the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\ in the registry editor.
    So, I created a reg file to create the extra folders and add those keys you specified.

    After restarting my machine, I still cannot get VS2008 to recognize the html5 tags.
    Is there anything I missed?

    A side note:
    When I hovered over to the green warning line, VS is validating the tags using XHTML 1.0 Transitional. When I wanted to change the HTML Validation setting to HTML 5, I could not find the option.

    Thanks,

    Vivian

  14. Carlo G. says:

    Hi John, I can’t download the XSD file (the link gives a 404 error).
    Can you fix it?
    thanks in advance for your work

  15. Neil Monroe says:

    John,
    I am getting a bad link also when trying to grab the XSD file. Do you still have this schema file available for download?

    Thanks.

  16. Hi John, I can’t download the XSD file TOO (the link gives a 404 error).

  17. Yamraj Pandya says:

    Thank you Sir, this will help me lot… thanks again

Leave a Reply

Hi, I'm John Dyer. In my day job, I build websites and create online seminary software for a seminary in Dallas. I also like to release open source tools including a pretty popular HTML5 video player and build tools that help people find best bible commentaries and do bible study. And just for fun, I also wrote a book on the theology of technology and media.

Fork me on GitHub

Social Widgets powered by AB-WebLog.com.