Horje

How to Use CSS to style buttons (with hover effect)

The button element - Styled with CSS

Use the :hover selector to change the style of the button when you move the mouse over it.

Tip: Use the transition-duration property to determine the speed of the "hover" effect:

index.html
Example: HTML
 <!DOCTYPE html>
<html>
<head>
<style>
.button {
  border: none;
  color: white;
  padding: 16px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  transition-duration: 0.4s;
  cursor: pointer;
}

.button1 {
  background-color: white;
  color: black;
  border: 2px solid #04AA6D;
}

.button1:hover {
  background-color: #04AA6D;
  color: white;
}

.button2 {
  background-color: white;
  color: black;
  border: 2px solid #008CBA;
}

.button2:hover {
  background-color: #008CBA;
  color: white;
}

</style>
</head>
<body>

<button class="button button1">Green</button>
<button class="button button2">Blue</button>

</body>
</html> 

Output should be:

How to Use CSS to style buttons (with hover effect)



Single Articles
Example of HTML <button> TagHTML Button
Definition and Usage of HTML <button> TagHTML Button
Browser Support of HTML <button> TagHTML Button
Attributes of HTML <button> TagHTML Button
Global Attributes of HTML <button> TagHTML Button
Event Attributes of HTML <button> TagHTML Button
How to add A clickable button is marked up as followsHTML Button
How to Use CSS to style buttonsHTML Button
How to Use CSS to style buttons (with hover effect)HTML Button


Related Articles
HTML <button> Tag HTML Button

Type:
html
Category:
Web Tutorial
Sub Category:
HTML Button
Uploaded by:
Admin