DEV Community

loading...

Discussion on: How to create an HTML button that acts like a link?

Collapse
adam_cyclones profile image
Adam Crockett

Okay so theres a few issues with Example 2.

The form action attribute as I have read it in HTML5 spec (this is not a common attribute 🦄), This is designed to give a <form> the ability to POST to several different urls - an unusual case but anyway such is the way of the web. A button hacked into a link in this way will not be counted towards SEO is another reason not to use this method.

The solution to navigation is the idiomatic <a href=""/> anchor and thats it really. There is then no need to have a style to make a button look like a link.

If you can give me a use case I can try illustrate it more clearly.

Thread Thread
link2twenty profile image
Andrew Bone

These are probably the best ways to use a button as an anchor with the former being best.

Thread Thread
adam_cyclones profile image
Adam Crockett

Sorry my friend it's not valid HTML5 according to the HTML5 Spec Document from W3C:

html.spec.whatwg.org/multipage/tex...

Still works I guess