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

后端 未结 30 3573
长发绾君心
长发绾君心 2020-11-21 04:18

I would like to create an HTML button that acts like a link. So, when you click the button, it redirects to a page. I would like it to be as accessible as possible.

30条回答
  •  死守一世寂寞
    2020-11-21 05:10

    Another option is to create a link in the button:

    
    

    Then use CSS to style the link and button, so that the link takes up the entire space within the button (so there's no miss-clicking by the user):

    button, button a{position:relative;}
    button a{top:0;left:0;bottom:0;right:0;}
    

    I have created a demo here.

提交回复
热议问题