Vertical alignment in Bootstrap with Examples
Vertical Alignment in bootstrap changes the alignment of elements vertically with the help vertical-alignment utilities. The vertical-align utilities only affects inline(Present in one Line), inline-block(Present as blocks in one line), inline-table, and table cell(Elements in a cell of a table) elements.
Various classes available in bootstrap library that are used for vertical alignment are:
- .align-baseline
- .align-top
- .align-middle
- .align-bottom
- .align-text-bottom
- .align-text-top
Below examples illustrate the vertical alignment classes in Bootstrap:
Example 1: With Inline Elements
<!-- BootStrap Vertical alignment classes for inline elements --> <!DOCTYPE html> <html> <head> <title>GeeksForGeeks</title> <link rel="stylesheet" </head> <body> <div class="container"> <h1>Vertical Align</h1> <p> Change the alignment of elements with the align classes (only works on inline, inline-block, inline-table and table cell elements): </p> <span class="align-baseline">Hello</span> <span class="align-top">This</span> <span class="align-middle">is</span> <span class="align-bottom">Geeks</span> <span class="align-text-top">for</span> <span class="align-text-bottom">Geeks</span> </div> </body> </html> |
Output:

Example 2: With Table Cells.
<html> <head> <title>GeeksForGeeks</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> </head> <body> <div class="container"> <table class='table table-striped table-bordered' style="height: 100px;"> <tbody> <tr> <td class="align-baseline"> Hello </td> <td class="align-top"> This </td> <td class="align-middle"> is </td> <td class="align-bottom"> Geeks </td> <td class="align-text-top"> for </td> <td class="align-text-bottom"> Geeks </td> </tr> </tbody> </table> </div> </body> </html> |
Output:

Reference: https://getbootstrap.com/docs/4.1/utilities/vertical-align/
Recommended Posts:
- How to set the button alignment in Bootstrap ?
- BootStrap | Text Utilities (Alignment, Wrapping, Weight etc.)
- Bootstrap (Part-4) | Vertical Forms, Horizontal Forms, Inline Forms
- Popovers in bootstrap with examples
- Borders in bootstrap with examples
- Bootstrap Buttons with Examples
- Spacing in Bootstrap with Examples
- Containers in Bootstrap with examples
- Shadows in Bootstrap with Examples
- Bootstrap | Sizing an element with Examples
- Responsive images in Bootstrap with Examples
- Media Objects in Bootstrap with Examples
- Bootstrap | figure class with Examples
- Input Groups in Bootstrap with Examples
- Display Property in Bootstrap with Examples
- Bootstrap | Float utilities with Examples
- BootStrap | Positioning an element with Examples
- List group in bootstrap with examples
- Colors and gradients in bootstrap with examples
- Visibility of elements in bootstrap with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

