Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Bootstrap5 Form Floating Labels

Bootstrap5 Form Floating Labels

By default, label content is usually displayed above the input field:

With floating labels, you can insert a label inside the input field and make it float upward when the input is clicked

Bootstrap Examples

<div class=">

form-floating mb-3 mt-3

"

<input type="text" class="form-control" id="email" placeholder=">

Enter email

"

name

=

"

email

"

<label for="email" Email label div>
<div class=">

form-floating mt-3 mb-3

"

<input type="text" class="form-control" id="pwd" placeholder=">

Enter password

"

name

=

"

pswd

"

<label for="pwd" Password label div>

Try it »

Notes:

Text box

The textarea text box can also have floating effects:

Bootstrap Examples

<

div

class

=

"

form-floating

"

<

textarea

class

=

"

form-control

"

id

=

"

comment

"

name

=

"

text

"

placeholder

=

"

Comment goes here

"

textarea

<label for="comment" Comments label div>

Try it »

Select box

We can use floating labels on the select menu; they will always be displayed in the upper-left corner of the select menu, without the click-to-float effect:

Bootstrap Examples

<div class="form-floating">
<select class="form-select" id="sel1" name="sellist">
<option1 option>
<option2 option>
<option3 option>
<option4 option select>
<label for="sel1" class="form-label">

Select list (select one):

label

div

Try it »