End tag is missing matching start tag

2019-08-11 06:35发布

I have the following code/markup in my Index.cshtml:

<p>
    @Html.ActionLink("Create New", "Create")

    @using (Html.BeginForm("Index", "Clients", FormMethod.Get))
    {
    <p>
        Title: @Html.TextBox("search") <br />
        <input type="submit" value="Search" />
    </p>
    }
</p>

Visual Studio 2013 warns me that the last line (</p>) doesn't have a start tag. I don't have any other <p> or </p> tags in the document. What's going on?

Full warning message: End tag is missing matching start tag.

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-08-11 07:03

Two important facts about paragraphs:

  • The end tag for p elements is optional.
  • p elements cannot contain other p elements.

This means that:

  1. The first p start tag opens the first p element.
  2. The second p start tag closes the first p element then opens the second p element.
  3. The first p end tag closes the second p element.
  4. The second p end tag has no open p element to close.
查看更多
登录 后发表回答