Create a Vertical Button Group with CSS

The vertical button group in CSS allows you to stack buttons one below the other, creating a clean and organized navigation or action menu. This layout is useful for sidebars, navigation panels, or any interface where you need buttons arranged vertically.

Syntax

.button-group .button {
    display: block;
    width: 100%;
}

Example

The following example creates a vertical button group with styled buttons ?

<!DOCTYPE html>
<html>
<head>
<style>
    .mybtn .button {
        background-color: orange;
        border: 1px solid green;
        width: 120px;
        color: white;
        font-size: 14px;
        padding: 10px;
        text-align: center;
        text-decoration: none;
        display: block;
        margin-bottom: 5px;
        cursor: pointer;
    }
    
    .mybtn .button:hover {
        background-color: #ff8c00;
    }
    
    .mybtn .button:last-child {
        margin-bottom: 0;
    }
</style>
</head>
<body>
    <div class="mybtn">
        <button class="button">Home</button>
        <button class="button">About</button>
        <button class="button">Services</button>
        <button class="button">Contact</button>
    </div>
</body>
</html>
Four orange buttons with green borders are stacked vertically. Each button is 120px wide with white text. The buttons change to a darker orange on hover.

Key Properties

Property Value Purpose
display block Makes buttons stack vertically
width 120px Sets uniform button width
margin-bottom 5px Creates spacing between buttons

Conclusion

Creating vertical button groups is straightforward using display: block and consistent styling. Add hover effects and proper spacing for better user experience and visual appeal.

Updated on: 2026-03-15T13:03:14+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements