0

I created my portfolio but unfortunately I cannot use a button properly. What did I wrong?

On Chrome it does work pretty well!

friendly regard

<button><a href="portfolio.html">Check Portfolio</a></button>

2 Answers2

2

The proper method to implement this is to stick the button inside of a form with method="get" and an action attribute with the site you are linking to.

You can also use JavaScript to set an event handler on the click event of the button.

Also, you can use CSS to make an anchor tag look like a button.

The one route NOT to go is wrapping a button in an a or vice-versa. It's not proper HTML.

SomeShinyObject
  • 7,581
  • 6
  • 39
  • 59
0

if you use an A tag, you stick the button inside it also, you should use the full url, unless its in the current directory the webpage is in. For example:

 <a href="https://www.google.com"><button> Click Here to Google! </button></a>
drtechno
  • 298
  • 2
  • 9
  • Thank you! It helped a lot! But do you always have to write full URL, even if you use for your own site? – Leandra Hartmann Jan 21 '18 at 23:44
  • if its on the site itself, you can just put the file name in the href if its in the same directory. Some hosting servers need "/filename.html" instead of "filename.html" because of its path settings. – drtechno Jan 22 '18 at 01:03
  • This solution is wrong: this is **NOT** valid HTML5. See the related question [here](https://stackoverflow.com/questions/6393827/can-i-nest-a-button-element-inside-an-a-using-html5?noredirect=1&lq=1) – Dexter Jan 22 '18 at 08:27
  • there are several ways to make a button link @Dexter. you can use the java window location with the onclick attribute, if you want to use the html5 button formaction attribute (seems clumsy to have to put form tags around a button so the form attribute works, but ok) – drtechno Jan 22 '18 at 14:12