-3

I'm only just learning html and have a question about linking a button. Could you tell me what I am doing wrong here?

</style>
<body>
<button onClick="name.html" class="button" ><span>name </span> </button>
<br>
Ivar
  • 6,138
  • 12
  • 49
  • 61
  • 2
    Why not use an [`a`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) tag if you want to redirect to a new page: `Maroeska ` – Hao Wu Oct 20 '20 at 10:18
  • 1
    A [button](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button) is not an [anchor](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) (aka link), it's worth reading the documentation I've linked and understanding the differences. – DBS Oct 20 '20 at 10:23

1 Answers1

1

In your application you should rather use an anchor link, because the button mostly used in forms. The corresponding HTML tag is <a>. If you want to make your link look like a button you can give it a class and design it with CSS.

<a href="name.html" class="button">name</a>

   
<style>
    .button {
          background-color: #4CAF50;
          border: none;
          color: white;
          padding: 15px 32px;
          text-align: center;
          text-decoration: none;
          display: inline-block;
          font-size: 16px;
    }
</style>