asp.net-mvc – HTML5元素的“传说”太少了

我在MVC中有以下视图,并且会收到警告消息:验证(HTML5):元素“图例”发生的次数太少
@model Berwin.Models.viewmodels.Userviewmodel

@{
ViewBag.Title = "Press";
}

<h2>Press Area</h2>

@using (Html.BeginForm("Register","PressController",FormMethod.Post))
{
<fieldset>
    @Html.TextBoxFor(model => model.FullName)
</fieldset>

<fieldset>
    @Html.TextBoxFor(model => model.Company)
</fieldset>

<fieldset>
    @Html.TextBoxFor(model => model.EmailAddress)
</fieldset>

<fieldset>
    @Html.CheckBoxFor(model => model.JoinMailingList)
</fieldset>
}

想知道为什么我得到这个警告,我需要做什么来解决这个问题。

解决方法

根据HTML 5规范,< legend>标记不是< fieldset>中的必需元素。

The legend element represents a caption for the rest of the contents
of the legend element’s parent fieldset element,if any.

文件http://www.w3.org/TR/html5/forms.html#the-legend-element

在您的情况下,它只是由Visual Studio插件提供的警告。它不是必需的,并且可能有一种方法来抑制“工具” – “选项” – “文本编辑器” – “HTML – 验证”下的警告。在这里,您还可以切换验证的目标(HTML 5,XHTML 1等)

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....