I have tried one way to do it:
<button href='www.google.com'>Google</button>.
But that didn't work. Can anyone find a solution? I would like to find out how to do this.
 
    
    - 25
- 1
- 6
- 
                    You create a link and then use CSS to style it to resemble a button – j08691 Jun 13 '21 at 17:38
- 
                    Can you link to the authoritative source on which you are basing your implicit claim that an `href` attribute on a `button` element is valid HTML? – esqew Jun 13 '21 at 17:39
4 Answers
Nest the button in an anchor:
<a href='https://www.google.com'><button>Google</button></a>Or wrap it in a form (in compliance with the HTML 5 Specs):
<form style="display: inline" action="https://www.google.com" method="get">
  <button>Google</button>
</form>Alternatively, you can use JS to attach a click event listener that changes window.location:
document.querySelector('button').onclick=function(){
  window.location = this.getAttribute('href');
}<button href='https://www.google.com'>Google</button> 
    
    - 30,714
- 6
- 20
- 43
you can create by writing the code like this
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
<button><a href='https://stackoverflow.comcquestions/' target="_blank">Google</a></button>
</body>
</html>
 
    
    - 49
- 8
button element hasn't a href attribute. You can use a tag instead of a button.
And add a class name to the  tag and you can set a style to the  tag.
If you use bootstrap, please add btn class name to the  tag.
Let me know if it works for you or not.
<a href='https://www.google.com' class="btn">Google</a> 
    
    - 962
- 1
- 12
- 30
There is a difference between a button and an anchor tag.
<a> - To navigate to other resources. (Hence it has the href attribute. Here 'navigate' must be an anchor tag.)
<button()> - To perform an action. (Add Comment on this page must be a button tag.)
You should not be mixing them. Use CSS to change your 's styling to look like the button you want.
Following semantic HTML is a good practice, especially for accessibility reasons.
 
    
    - 16,452
- 1
- 18
- 39