CSS Buttons
CSS Buttons
w3schools.com
CSS Buttons
❮ Previous Next ❯
Example
.button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
Try it Yourself »
Button Colors
https://www.w3schools.com/css/css3_buttons.asp 1/11
8/9/2017 CSS Buttons
Example
Try it Yourself »
Button Sizes
Example
Try it Yourself »
https://www.w3schools.com/css/css3_buttons.asp 2/11
8/9/2017 CSS Buttons
Example
Try it Yourself »
Rounded Buttons
Example
Try it Yourself »
https://www.w3schools.com/css/css3_buttons.asp 3/11
8/9/2017 CSS Buttons
Example
.button1 {
background-color: white;
color: black;
border: 2px solid #4CAF50; /* Green */
}
...
Try it Yourself »
Hoverable Buttons
Use the :hover selector to change the style of a button when you move the mouse over it.
Tip: Use the transition-duration property to determine the speed of the "hover" effect:
Example
.button {
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
https://www.w3schools.com/css/css3_buttons.asp 4/11
8/9/2017 CSS Buttons
.button:hover {
background-color: #4CAF50; /* Green */
color: white;
}
...
Try it Yourself »
Shadow Buttons
Example
.button1 {
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
.button2:hover {
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0
rgba(0,0,0,0.19);
}
Try it Yourself »
Disabled Buttons
https://www.w3schools.com/css/css3_buttons.asp 5/11
8/9/2017 CSS Buttons
Use the opacity property to add transparency to a button (creates a "disabled" look).
Tip: You can also add the cursor property with a value of "not-allowed", which will display a "no
parking sign" when you mouse over the button:
Example
.disabled {
opacity: 0.6;
cursor: not-allowed;
}
Try it Yourself »
Button Width
250px
50%
100%
By default, the size of the button is determined by its text content (as wide as its content). Use
the width property to change the width of a button:
Example
Try it Yourself »
https://www.w3schools.com/css/css3_buttons.asp 6/11
8/9/2017 CSS Buttons
Button Groups
Button Button Button Button
Remove margins and add float:left to each button to create a button group:
Example
.button {
float: left;
}
Try it Yourself »
Example
.button {
float: left;
border: 1px solid green;
}
Try it Yourself »
https://www.w3schools.com/css/css3_buttons.asp 7/11
8/9/2017 CSS Buttons
Button
Button
Button
Use display:block instead of float:left to group the buttons below each other, instead of
side by side:
Example
.button {
display: block;
}
Try it Yourself »
Animated Buttons
Example
Add an arrow on hover:
Hover
Try it Yourself »
Example
Add a "pressed" effect on click:
https://www.w3schools.com/css/css3_buttons.asp 8/11
8/9/2017 CSS Buttons
Click
Try it Yourself »
Example
Add a "ripple" effect on click:
Click
Try it Yourself »
❮ Previous Next ❯
COLOR PICKER
LEARN MORE
Tabs
Dropdowns
Accordions
Convert Weights
Animated Buttons
Side Navigation
Top Navigation
https://www.w3schools.com/css/css3_buttons.asp 9/11
8/9/2017 CSS Buttons
JS Animations
Modal Boxes
Progress Bars
Parallax
Login Form
HTML Includes
Google Maps
Loaders
Tooltips
Slideshow
Filter List
Sort List
SHARE
CERTIFICATES
HTML, CSS, JavaScript, PHP, jQuery, Bootstrap and XML.
Read More »
REPORT ERROR
PRINT PAGE
FORUM
ABOUT
Top 10 Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
W3.CSS Tutorial
Bootstrap Tutorial
SQL Tutorial
PHP Tutorial
jQuery Tutorial
Angular Tutorial
XML Tutorial
https://www.w3schools.com/css/css3_buttons.asp 10/11
8/9/2017 CSS Buttons
Top 10 References
HTML Reference
CSS Reference
JavaScript Reference
W3.CSS Reference
Browser Statistics
PHP Reference
HTML Colors
HTML Character Sets
jQuery Reference
AngularJS Reference
Top 10 Examples
HTML Examples
CSS Examples
JavaScript Examples
W3.CSS Examples
HTML DOM Examples
PHP Examples
ASP Examples
jQuery Examples
Angular Examples
XML Examples
Web Certificates
HTML Certificate
CSS Certificate
JavaScript Certificate
jQuery Certificate
PHP Certificate
Bootstrap Certificate
XML Certificate
W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic
understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full
correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy
policy. Copyright 1999-2017 by Refsnes Data. All Rights Reserved.
Powered by W3.CSS.
https://www.w3schools.com/css/css3_buttons.asp 11/11