简体   繁体   English

杂散结束标签“表格”

[英]Stray end tag “form”

I am getting error Stray end tag "form" in below HTML code.我在 HTML 代码下方收到错误Stray end tag "form"

 <section class="login-section reg-section card"> <div class="container"> <div class="row mt-5 "> <div class="col-md-6"> <div class="reg-left"> <h3>Account Login Details</h3> <form method="POST" action=""> <div class="form-group"> <label for="email">Email Address*</label> <input value="" type="email" name="reg_email" class="form-control " placeholder="Email" id="login_email" required> </div> <div class="form-group"> <label for="password">Password*</label> <input type="password" name="password" class="form-control " placeholder="Password" required> </div> <div class="form-group"> <label for="password_confirmation">Confirm Password*</label> <input type="password" name="password_confirmation" class="form-control " placeholder="Confirm Password" required> </div> </div> <button type="submit" class="btn">Submit</button> </form> </section>

在此处输入图像描述

Why I am getting this error?为什么我收到此错误? Why the tags are red?为什么标签是红色的? How can I fix it?我该如何解决?

You have an extra closing div tag at line 123, as highlighted by your editor in your screenshot.您在第 123 行有一个额外的结束div标记,正如您的编辑器在屏幕截图中突出显示的那样。

The red in the screenshots are indicating issues with your html structure.屏幕截图中的红色表示您的 html 结构存在问题。 The form and div tags need to have associated closing tags that allow them to wrap their contents. formdiv标签需要有关联的结束标签,允许它们包装它们的内容。 As is, you are closing a div that doesn't have an associated "opening" tag within its direct parent.照原样,您正在关闭一个在其直接父级中没有关联的“开始”标签的div

Delete the extra closing div tag to fix the current errors, then you'll probably need to close the remaining div tags within your section .删除额外的关闭div标签以修复当前错误,然后您可能需要关闭section中剩余的div标签。

You close the that contains the form and try to close the form afterward.您关闭包含表单的表单,然后尝试关闭表单。

try closing the div after you close the form.关闭表单后尝试关闭 div。

the correct way of how your form should look like:你的表单应该是什么样子的正确方法:

<form method="POST" action="">
  <div class="form-group">
    <label for="email">Email Address*</label>
    <input value="" type="email" name="reg_email" class="form-control " placeholder="Email" id="login_email" required>
  </div>
  <div class="form-group">
    <label for="password">Password*</label>
    <input type="password" name="password" class="form-control " placeholder="Password" required>
  </div>
  <div class="form-group">
      <label for="password_confirmation">Confirm Password*</label>
      <input type="password" name="password_confirmation" class="form-control " placeholder="Confirm Password" required>
  </div>
  <button type="submit" class="btn">Submit</button>
</form>

Firstly, look at your indentation - you have:首先,看看你的缩进 - 你有:

    <form>
        <div>
        </div>
        <div>
        </div>
        <div>
        </div>
</div>
</form>

So your core problem is that that red-coloured end-div tag does not match an opening div tag, so the solution is to just delete it.所以你的核心问题是那个红色的 end-div 标签与打开的 div 标签不匹配,所以解决方案就是删除它。

In addition, you are not closing your input tags;此外,您没有关闭输入标签; have them finish with />.让他们以 /> 结尾。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM