因此我有一个布局页面
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
<link href="@Url.Content("~/content/main_layout.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/content/menu.css")" rel="stylesheet" type="text/css" />
@RenderSection("JS", required:false)
@RenderSection("CSS", required:false)
</head>
<body>
@RenderBody()
</body>
</html>
然后是这样的视图
@{
ViewBag.Title = "Home";
Layout = "~/views/shared/_layout.cshtml";
}
@using RS.Common.HtmlHelpers;
@section JS
{
<script src="@Url.Content("~/scripts/fue.js")" type="text/javascript"></script>
<script src="@Url.Content("~/scripts/jquery.flexslider-min.js")" type="text/javascript"></script>
}
@section CSS
{
<link href="@Url.Content("~/content/hp.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/content/hp_form.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/content/flexslider.css")" rel="stylesheet" type="text/css" />
}
<h4>Test!</h4>
页面加载正常,如我所料。但是,我收到 3 个警告:
Validation (XHTML 1.0 Transitional): Element 'link' cannot be nested within element 'link'
此错误针对视图上 CSS 部分中的每个标记。
在这个阶段这只是一个烦恼,但我想知道这个错误的原因(以及解决方案)可能是什么?