button in html code example

Example 1: how to add buttons in html

<button type="button" onclick="alert('You pressed the button!')">Click me!</button>

Example 2: button functions html

<script>
 function myFunction() {
   alert("ALERT");
 }
</script>
<button onclick="myFunction">Click</button>

Example 3: how to make a button in html

<!--Button Element-->
<button>This is a Button!</button>
<!--Button with a link-->
<a href="blah blah blah" target="_blank"><button>Button w/ Link!</button></a>

Example 4: html button

<html>
  <head>
        <style>
          .button {
 			background-color: <background color>;
  			border: none;
 			color: <text color>;
  			padding: 10px 25px;
  			text-align: center;
 			text-decoration: none;
  			display: inline-block;
  			font-size: 16px;
  			margin: 4px 4px;
  			cursor: pointer;
  			border-radius: 8px;
			}
  		</style>
	</head>
	<body>
      <a href="<url>" class="button">ButtonText</a>
 	</body>
</html>

Example 5: how to make a button in html

<button>I'm a button</button>

Example 6: button in html

<button></button>