VOOZH about

URL: https://www.geeksforgeeks.org/bootstrap/bootstrap-5-floating-labels/

⇱ Bootstrap 5 Floating labels - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Bootstrap 5 Floating labels

Last Updated : 23 Jul, 2025

Bootstrap 5 floating labels are form labels that float over input fields, improving UX. Wrap form controls like <input>, <label>, <textarea>, <select> inside <div> with class .form-floating. Ensure these elements precede <label> inside the floating <div>.

Bootstrap 5 Floating labels:

ComponentDescription
TextareasUse CSS height property for Floating label Textarea, adjusting height similar to the input.
SelectsUtilize Floating labels Component Selects for input fields with floating labels.
LayoutEmploy Floating labels Layout within a grid system, placing form elements within column classes.
SassCustomize Floating labels by adjusting default values in Bootstrap 5 SCSS files for tailored usage.

Syntax:

<div class="form-floating"> ...</div>

Examples of Bootstrap 5 Floating labels

Example 1: In this example, <input>, <textarea>, and <label> elements are wrapped inside <div> element with .form-floating class.

Output:


👁 Floating-label
Bootstrap 5 Floating labels Example Output

Example 2: In this example, <select> and <label> elements are wrapped inside <div> element with .form-floating class.

Output:

👁 Floating-label2
Bootstrap 5 Floating labels Example Output
Comment

Explore