Cancel button in html

1.1k Views Asked by At

How do you make a cancel button in a form that will return you to the home page? I do not know where to start for it. Tried to create it already with no good result. Keep getting a ticked box. Any ideas?

1

There are 1 best solutions below

0
Three Year Old On

According to @vee's comment:

Fake button with anchor element:

a.button {
  -webkit-appearance: button;
  -moz-appearance: button;
  appearance: button;

  background: #e9e9ed;

  text-decoration: none;
  color: initial;

  border: 1px #8f8f9d solid;
  border-radius: 3px;

  padding: 2px 5px;

  font-family: Tahoma;
  font-size: small;
}

a.button:hover {
  background: #d0d0d7;

  border-color: #676774;
}
<a href="/" class="button">Button</a>

Real button with JavaScript click event:

document.getElementById('button').addEventListener('click', function(e) {
  e.preventDefault();
  window.location.href = '/';
});
input#button {
  cursor: pointer;
}
<input value="Button" type="button" id="button" />