Some days ago I installed the ASP.NET MVC 3 Tools Update for Visual Studio 2010.
Just now I went to create a new ASP.NET MVC 3 application and I see that there's a new option on the New ASP.NET MVC 3 Project
dialog:
use HTML5 semantic markup
What does selecting this checkbox change in the newly created app compared to not selecting it, other than the literally obvious?
When would you definitely not want to use it, only to keep compatibility with old browsers?
Look at the _Layout.cshtml
. You will notice HTML5 tags such as <header>
and <section>
. It also includes the modernizr
javascript plugin to the project.
When would you definitely not want to use it, only to keep compatibility with old browsers?
If you don't want to use HTML5 specific tags. Anyway, it's just a checkbox generating a bunch of default markup that you could modify at any moment if you will. So you are not engaging yourself with anything that cannot be undone subsequently. If you are starting a new project, go ahead and check it :-)
The answer somewhat depends on which project template you select. (Empty, Internet Application, or Intranet Application)
If you select Empty, the checkbox adds the following two lines to the <head>
section in your _Layout.cshtml.
<meta charset="utf-8" />
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")"
type="text/javascript"></script>
If you select Internet or Intranet Application, then in addition to the two lines above, you will see HTML5 semantic markup tags instead of divs in your _Layout.cshtml markup shown below:
HTML5 Box Checked vs. Not Checked
<header> <div id="header">
<nav> <div id="menucontainer">
<section id="main"> <div id="main">
<footer> <div id="footer">
I see no reason not to check it, but it does not really matter. As mentioned by Darin, the checkbox value is just for determining which markup is generated for you. The value is not stored in your project.
You can read more in Scott Gu's blog post:HTML5 Improvements with the ASP.NET MVC 3 Tools Update
The check box dictates the inclusion of Modernizr with your views, I don't believe there is anything else different than when not checked.
来源:https://stackoverflow.com/questions/5721056/new-use-html5-semantic-markup-option-on-file-new-mvc-3-project