Floating Labels have become a popular feature in Bootstrap 5.2.
To implement floating labels, simply wrap
<input class="form-control">
and
<label>
elements within a
.form-floating
container. Make sure to include a placeholder text in each
<input>
to make use of the
:placeholder-shown
pseudo-element. Remember that the
<input>
should precede the
<label>
for proper functionality.
<div class="form-floating mb-3">
<input type="email" class="form-control" id="floatingInput" placeholder="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="385659555d785d40595548545d165b5755">[email protected]</a>">
<label for="floatingInput">Email address</label>
</div>
<div class="form-floating">
<input type="password" class="form-control" id="floatingPassword" placeholder="Password">
<label for="floatingPassword">Password</label>
</div>