How to create a button in HTML

There are two ways to create a button in HTML. One is with the <button> tag, and the other is with the <input> tag.

What's the difference? The <button> tag allows you to use HTML inside of your button (so you could bold certain letters on the button's text, etc).

The button tag

Here is a button tag:

<button id="mybutton">Click me</button>

The result:

a button on a webpage

The input tag

Here is an input tag:

<input type="button" value="Click me too">

The result:

input button on a webpage

The input tag does not need a closing tag.

Next: How to create a single-line text input in HTML

Comments

Leave a comment

What color are green eyes? (spam prevention)
Submit
Code under MIT License unless otherwise indicated.
© 2020, Downranked, LLC.