Which attribute to add a button to make it work?

Good time of day. Read the book "the New big book of CSS" (orig. CSS The Missing Manual 4th Edition) by David Mcfarland, and was found in it such code:

<button>
 <a href="#signupForm">Sign up for our newsletter</a>
</button>
 <form id="signupForm">
 <label for="email">Enter your email address</label>
 <input type="email" id="email">
 <input type="submit" value="Subscribe" class="btn">
 </form>


By clicking on the link, the page needs to "transfer" to the form and to the address in the address bar - added #signupForm, but, alas, this is not happening. Without reversing the links in the button it works, so I suspect that the problem lies in the unspecified any attribute to a button. In fact, asking for help :)

JS Bin
July 2nd 19 at 13:42
2 answers
July 2nd 19 at 13:44
Solution
<a href="#signupForm">Sign up for our newsletter</a>
<br / >
 <form id="signupForm">
 <label for="email">Enter your email address</label>
 <input type="email" id="email">
 <input type="submit" value="Subscribe" class="btn">
 </form>
Well, button and I clean, and if from button, how? - skyl commented on July 2nd 19 at 13:47
: crutch, I never showed that to you ) Shhh....
<button type="button" onclick="location.href='#signupForm'">Subscribe</button>
 <div style="padding: 0 900px"></div>
 <form id="signupForm">
 <label for="email">Enter your email address</label>
 <input type="email" id="email">
 <input type="submit" value="Subscribe" class="btn">
 </form>
- Vernon.Schu commented on July 2nd 19 at 13:50
: Thank you - skyl commented on July 2nd 19 at 13:53
July 2nd 19 at 13:46
Solution
Here is a list of all attributes: https://developer.mozilla.org/en-US/docs/Web/HTML/...

But it's not really a valid layout. If you want you can wrap the opposite button in the link or add the link to the button class, so they were visually similar.

Find more questions by tags HTML