Visual Studio HTML5验证:元素'img'不能嵌套在元素'a'中 [英] Visual Studio HTML5 Validation: Element 'img' cannot be nested within element 'a'

查看:213
本文介绍了Visual Studio HTML5验证:元素'img'不能嵌套在元素'a'中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Visual Studio 2010中遇到了这个奇怪的验证错误,并且选择了HTML5验证:



这是验证错误(合法还是Visual Studio中的错误)还是我错过了某些明显的简单?




编辑:添加了相关代码。

查看 cshtml

  @model My。 Web.ViewModels.ListVideos 

@ {
ViewBag.Title =All Videos;
}

@foreach(Model.Videos中的var item){
< a href =@ Url.Action(Play,Player,new {videoId = item.VideoId})>
< img src =http://i2.ytimg.com/vi/@item.PublisherVideoId/default.jpgalt =@ item.Titlestyle =border:0/>
< / a>

_Layout.cshtml

 <!DOCTYPE html> 
< html>
< head>
< meta charset =utf-8/>
< title> @ ViewBag.Title< / title>
< link href =@ Url.Content(〜/ Content / Site.css) =stylesheettype =text / css/>
< script src =@ Url.Content(〜/ Scripts / jquery-1.6.4.min.js)type =text / javascript>< / script>
< script src =@ Url.Content(〜/ Scripts / modernizr-1.7.min.js)type =text / javascript>< / script>
< / head>
< body>
< div class =page>
< header>
< div id =title>
< h1>我的网页< / h1>
< / div>
< div id =logindisplay>
@ Html.Partial(_ LogOnPartial)
< / div>
< nav>
< ul id =menu>
< li> @ Html.ActionLink(视频,ListVideos,玩家)< / li>
< li> @ Html.ActionLink(Dev,Index,Dev)< / li>
< / ul>
< / nav>
< / header>
< section id =main>
@RenderBody()
< / section>
< footer>
< / footer>
< / div>
< / body>
< / html>


解决方案

您需要使用visual studio 2010 SP1 web标准更新这个工作正常。这是一个bug。



更多信息:http://blogs.msdn.com/b/webdevtools/archive/2011/06/15/web-standards- update-for-visual-studio-2010-sp1.aspx?PageIndex = 2

获取网络标准更新:
http://visualstudiogallery.msdn.microsoft.com/a15c3ce9-f58f-42b7-8668-53f6cdc2cd83

I've run into this curious validation error in Visual Studio 2010 with HTML5 validation selected:

Is this a validation error (legitimate or a bug in Visual Studio) or am I missing something obvious and simple?


Edit: added relevant code.

View cshtml:

@model My.Web.ViewModels.ListVideos

@{
    ViewBag.Title = "All Videos";
}

@foreach (var item in Model.Videos) { 
    <a href="@Url.Action("Play", "Player", new { videoId = item.VideoId })">
        <img src="http://i2.ytimg.com/vi/@item.PublisherVideoId/default.jpg" alt="@item.Title" style="border: 0" />
    </a>
}

_Layout.cshtml:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.6.4.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
</head>
<body>
    <div class="page">
        <header>
            <div id="title">
                <h1>My Web</h1>
            </div>
            <div id="logindisplay">
                @Html.Partial("_LogOnPartial")
            </div>
            <nav>
                <ul id="menu">
                    <li>@Html.ActionLink("Videos", "ListVideos", "Player")</li>
                    <li>@Html.ActionLink("Dev", "Index", "Dev")</li>
                </ul>
            </nav>
        </header>
        <section id="main">
            @RenderBody()
        </section>
        <footer>
        </footer>
    </div>
</body>
</html>

解决方案

You need visual studio 2010 SP1 web standards update to have this work properly. It is a bug.

See more here: http://blogs.msdn.com/b/webdevtools/archive/2011/06/15/web-standards-update-for-visual-studio-2010-sp1.aspx?PageIndex=2

Get the web standards update here: http://visualstudiogallery.msdn.microsoft.com/a15c3ce9-f58f-42b7-8668-53f6cdc2cd83

这篇关于Visual Studio HTML5验证:元素'img'不能嵌套在元素'a'中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆