0 votes
114 views
in HTML by (3.5k points)
edited

How to change button color in HTML?

1 Answer

0 votes
by (3.5k points)
edited

 

<!DOCTYPE html>
<html>
<head>
<style>
.button {
  background-color: #4CAF50; /* Green */
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
}
 
.buttondemo {background-color: #008CBA;} /* Blue */
.buttondemo2 {background-color: #f44336;} /* Red */ 
.buttondemo3 {background-color: #e7e7e7; color: black;} /* Gray */ 
.buttondemo4 {background-color: #555555;} /* Black */
</style>
</head>
<body>
 
<h2>Button Colors</h2>
<p>Change the background color of a button with the background-color property:</p>
 
<button class="button">Green</button>
<button class="button buttondemo">Blue</button>
<button class="button buttondemo2">Red</button>
<button class="button buttondemo3">Gray</button>
<button class="buttonbuttondemo4">Black</button>
 
</body>
</html>
 

Related questions

0 votes
1 answer 103 views
asked Aug 19, 2022 in HTML by codelikepro (3.5k points)
0 votes
1 answer 115 views
asked Aug 19, 2022 in HTML by codelikepro (3.5k points)
0 votes
1 answer 117 views
asked Aug 19, 2022 in HTML by codelikepro (3.5k points)
0 votes
1 answer 95 views
asked Aug 19, 2022 in HTML by codelikepro (3.5k points)
0 votes
1 answer 84 views
asked Jun 24, 2023 in HTML by Doubtly (98.9k points)
0 votes
1 answer 110 views
asked Aug 19, 2022 in HTML by codelikepro (3.5k points)

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

537 users

...