CSS Button Colors

Please Share On:

Definition:

CSS button colors can be changed by using background-color properties. See an example below of using background-color.

Syntax:

.button 
      {
       background-color: green; /* Here button background color is green*/
      } 

Source Code:

<!DOCTYPE html>
<html>
<head>
<style>
.button {
  background-color: green;
  color: white;
  padding: 10px 20px;
  text-align: center;
  text-decoration: none;
  margin-left: 30px;
  }
  
.btnblue {
  background-color: blue;
}
</style>
</head>
<body>
<h2>Button Colors</h2>
<button class="button">Green</button>
<button class="button btnblue">Blue</button>

</body>
</html>

Output:

Button Colors

In the above example, both button background-color properties are styled together as green, but the second button background-color is replaced by the second background-color and the first button background-color remains the same.

Therefore, the first background-color property is green and the second button background-color is blue.

See the above CSS style sheets for a better understanding. You can try changing into different background colors you like. Click the below button to try it yourself.


Donate to support writers.


You may interest on the following topics:

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright @2023. All Right Reserved.


Social media & sharing icons powered by UltimatelySocial