How TO - Button Group
Learn how to create a "button group" with CSS.
Horizontal Button Groups
Group a series of buttons together on a single line in a button group:
How To Create a Button Group
Step 1) Add HTML:
Example
  <div class="btn-group">
  <button>Apple</button>
  
  <button>Samsung</button>
  <button>Sony</button>
</div>
Step 2) Add CSS:
Example
  .btn-group button {
  background-color: #4CAF50; /* Green 
  background */
  border: 1px solid green; /* Green border 
  */
  color: white; /* White text */
  padding: 10px 
  24px; /* Some padding */
  cursor: pointer; /* 
  Pointer/hand icon */
  float: left; /* Float the 
  buttons side by side */
}
.btn-group button:not(:last-child) {
  border-right: none; /* Prevent double borders */
}
/* Clear floats (clearfix hack) */
.btn-group:after {
    
  content: "";
  clear: both;
  display: 
  table;
}
/* Add a background color on hover */
.btn-group button:hover {
  background-color: #3e8e41;
}
Try it Yourself »
Justified / Full-width Button Group:
Example
  <!-- Three buttons in a group -->
<div class="btn-group" style="width:100%">
  <button 
  style="width:33.3%">Apple</button>
  
  <button style="width:33.3%">Samsung</button>
  <button 
  style="width:33.3%">Sony</button>
</div>
<!-- 
  Four buttons in a group -->
<div class="btn-group" style="width:100%">
  <button 
  style="width:25%">Apple</button>
  
  <button style="width:25%">Samsung</button>
  <button 
  style="width:25%">Sony</button>
  <button 
  style="width:25%">HTC</button>
</div>
Try it Yourself »
Tip: Go to our CSS Buttons Tutorial to learn more about how to style buttons.

