New “use HTML5 semantic markup” option on File > New MVC 3 project

谁说胖子不能爱 提交于 2019-11-30 07:47:45

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

James Lawruk

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!