Dropdown menus help users pick options. Aligning them well makes the page look neat and easy to use.
Dropdown menu alignment in Bootsrap
Use these Bootstrap classes on the dropdown menu element: .dropdown-menu-start // aligns menu to the left .dropdown-menu-end // aligns menu to the right
These classes control where the dropdown menu appears relative to the toggle button.
Make sure your Bootstrap CSS is included for these classes to work.
<div class="dropdown"> <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Left Align </button> <ul class="dropdown-menu dropdown-menu-start"> <li><a class="dropdown-item" href="#">Action</a></li> </ul> </div>
<div class="dropdown"> <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Right Align </button> <ul class="dropdown-menu dropdown-menu-end"> <li><a class="dropdown-item" href="#">Action</a></li> </ul> </div>
This page shows two dropdown buttons. Each button's menu opens aligned differently: left and right. The menus have two items each. The page uses Bootstrap 5.3 CSS and JS from CDN.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Bootstrap Dropdown Alignment</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> </head> <body> <main class="p-4"> <h1>Dropdown Menu Alignment Examples</h1> <div class="mb-3"> <div class="dropdown"> <button class="btn btn-primary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Left Align </button> <ul class="dropdown-menu dropdown-menu-start" aria-label="Left aligned dropdown"> <li><a class="dropdown-item" href="#">Left Action 1</a></li> <li><a class="dropdown-item" href="#">Left Action 2</a></li> </ul> </div> </div> <div class="mb-3"> <div class="dropdown"> <button class="btn btn-success dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Right Align </button> <ul class="dropdown-menu dropdown-menu-end" aria-label="Right aligned dropdown"> <li><a class="dropdown-item" href="#">Right Action 1</a></li> <li><a class="dropdown-item" href="#">Right Action 2</a></li> </ul> </div> </div> </main> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> </body> </html>
Use aria-label on the dropdown menu for screen readers to improve accessibility.
Dropdown toggle buttons should have aria-expanded attribute updated automatically by Bootstrap.
Test dropdown alignment on different screen sizes to ensure good user experience.
Bootstrap provides classes to align dropdown menus: dropdown-menu-start and dropdown-menu-end.
Aligning dropdown menus helps keep your page tidy and easy to use.
Always include accessibility attributes like aria-label for better support.