Monday, February 10, 2014

MVC XHTML 1.0 Transitional "element is not supported XHTML"

While working with MVC 3 or MVC 4 applications I've noticed that some of my HTML tags show document validation warning messages such as "Element section is not supported".

This warning doesn't affect the rendering of the web page.  My first instinct was to Google the error.  There were solutions on the internet to removed or change the name of the ReflectedSchemas directory, but that didn't work for HTML5.  Plus, who wants to change the way Visual Studio does business, it would be best to configure the IDE for the appropriate environment instead of destroying its architecture.  Right!

THE SOLUTION:
When you create your MVC project with its appropriate HTML5 tags, you will get the validation warning message.

Do the following:

Make sure your document (_Layout) page is using HTML5 standards DocType declaration.


Set your Visual Studio to use HTML5
  1. Navigate to the Tools menu
  2. Options menu
  3. Choose the Text Editor node
  4. Choose the HTML node
  5. Select Validation
  6. Select HTML5 as the target
Warnings should immediately go away.