tag, as follows:
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="block">
<span class="col-lg-2 control-label">Email</span>
<div class="col-lg-10">
<input type="email" class="form-control">
</div>
</label>
</div>
</form>
While this approach may seem to solve the issue, it conflicts with HTML standards.
Addressing the Incompatibility
According to the HTML specification, a element cannot contain a element. The specification explicitly states that the
element's content model only allows phrasing content, which includes inline elements such as and , but not block-level elements like .
Therefore, nesting a block-level
inside the inline
element is incorrect behavior.
Possible Solution
If you wish to avoid using IDs for input fields while maintaining proper HTML structure, consider using the "for" attribute on the element to associate it with specific input fields:
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="inputEmail1" class="col-lg-2 control-label">Email</label>
<div class="col-lg-10">
<input type="email" class="form-control"> The above is the detailed content of Can I Nest a `` Inside a `` in a Bootstrap Form?. For more information, please follow other related articles on the PHP Chinese website!
Statement: The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn