HTML - 按钮 - 如何使它可以链接? [英] HTML - Button - How to make it linkable?

查看:109
本文介绍了HTML - 按钮 - 如何使它可以链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的按钮:

 <按钮>点击我< /按钮> 

我想让该按钮与href链接。是否符合HTML标准将按钮封装在标签中或将标签放在按钮内部以使其可链接?

谢谢

解决方案

您可能只想使用链接本身并将其设置为按钮样式。您仍然可以添加一个onclick,但它使链接到一个新页面非常容易。

  a.button {
颜色:#000000;
text-decoration:none;
display:block;
背景:#FFFFFF;
border:固体1px黑色;
}

不太吸引人(尽管常用)的方法是将链接图片。

 < a href =www.mysite.com/mypage>< img src =/ images /button.png\"/></a> 


I have a button like so:

<button>Click Me</button>

I want to make that button linked with an href. Is it compliant HTML to wrap the button in a tag or to put the tag inside of the button to make it linkable?

Thanks

解决方案

You may just want to use a link itself and style it like a button. You can still add an onclick, but it makes linking to a new page really easy.

a.button{
    color: #000000;
    text-decoration: none;
    display: block;
    background: #FFFFFF;
    border: solid 1px black;
}

A less appealing (though commonly used) method is to wrap a link around an image.

<a href="www.mysite.com/mypage"><img src="/images/button.png"/></a>

这篇关于HTML - 按钮 - 如何使它可以链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆