Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make a navigation button using a div with a link inside it

Tags:

html

css

button

i just started programming and I wanted to try css with html. However, I keep running into errors like these where I want a button, however when displayed on browser the said button becomes a link. can someone explain?

<!DOCTYPE html>

<html>
    <head>
        <meta charset="utf-8">
        <title>Linking External Style Sheets</title>

    <style>
      h1 {
        color: blue;
      }
      a {
        color: blue;
        text-decoration: none;
      }
      a:hover {
        background-color: yellow;
      }
    </style>
   </head>
   <body>
      <div><p><em>Click here:</em>
         <a class="w3-btn" href="http://www.w3schools.com">Link Button</a>
       </div>
    </body>
</html>

I wanted to give it a border, background and text color also, and make it change when theres a mouse over it with the code...

like image 607
david macklemore Avatar asked Jun 12 '26 06:06

david macklemore


1 Answers

If you want a button then simply use <button> instead of <a>:

<button class="w3-btn" href="http://www.w3schools.com">Link Button</button>

However, you can't use href with a button since buttons are suited for forms. In this case you can either style the link to look like a button (@RahulB answer) or wrap the (real) button in a form which submits to http://www.w3schools.com.

<form action="http://www.w3schools.com" method="POST">
         <button class="w3-btn" type="submit>Link Button</button>
</form>
like image 127
Hamza Ishak Avatar answered Jun 13 '26 20:06

Hamza Ishak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!