skip to Main Content

So, this is my code:

<button onclick="myFunction01()">...</button>

But the thing is that it’s grey now. And it’s not very apparent that it’s a button. How can I change the color of the button?

I tried to class it, but it didn’t work, I tried to make a div around it, but that also didn’t work. Is there any way to do this?

2

Answers


  1. Not sure what you mean by "I tried to class it" but here is how you can customize it.

    .my-button {
      color: white; /* text color */
      background-color: blue;
    }
    <button class="my-button">click me</button>
    Login or Signup to reply.
  2. The :active selector is used to select and style the active link. :

    <!DOCTYPE html>
    <html>
    <head>
        <style>
            .btn:active{
                background-color:blue;
             }
        </style>
    </head>
    <body>
        <button class="btn">click on me !</button>
    </body>
    </html>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search