Register Advertise with usHelp Desk Today's Posts Search

Thread Tools Search this Thread
Unread 11th Aug 2018, 06:11 PM   #1
Active Warrior
 
Join Date: 2009
Posts: 95
Thanks: 111
Thanked 8 Times in 7 Posts
Default
Combining the a href + button tag?
Share on: 
fb share twitter share gplus share more share

Would it cause any problems in the website or any browers?

<a href="whatever.html'><button>text in here</button></a>

Is there a better alternative? Thanks.

dansbanners is offline   Reply With Quote
Unread 12th Aug 2018, 05:07 AM   #2
New Warrior Member
 
Hasib Mahmud's Avatar
 
Join Date: 2018
Location: Bangladesh
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default
RE: Combining the a href + button tag?
Share on: 
fb share twitter share gplus share more share

Thanks, Brother
Hasib Mahmud is offline   Reply With Quote
Unread 12th Aug 2018, 09:37 AM   #3
Active Warrior
 
Join Date: 2009
Posts: 95
Thanks: 111
Thanked 8 Times in 7 Posts
Default
Re: Combining the a href + button tag?
Share on: 
fb share twitter share gplus share more share

Originally Posted by Hasib Mahmud View Post

Thanks, Brother
Glad you found it helpful. However, I'm wondering if it'll cause any problems or if there's a better way to do it, etc?

dansbanners is offline   Reply With Quote
Unread 14th Aug 2018, 12:07 AM   #4
Senior Warrior
War Room Member
 
Michael D Price's Avatar
 
Join Date: 2002
Location: Mobile, Al
Posts: 23
Thanks: 23
Thanked 16 Times in 14 Posts
Default
Re: Combining the a href + button tag?
Share on: 
fb share twitter share gplus share more share

To be honest,
I am a big fan of bootstrap.
Using bootstrap you can just apply a button style to an anchor link and get the desired visual effect of a button.

To do this without using booststrap, you should remove the button code, and just use css to style the link to look like a button.

For a more advanced method, use javascript for the linking.
https://codepen.io/svinkle/pen/FHGBh

Last edited on 14th Aug 2018 at 12:11 AM. Reason: Additional Resource
Michael D Price is offline   Reply With Quote
The Following 2 Users Say Thank You to Michael D Price For This Useful Post:
Unread 14th Aug 2018, 05:27 AM   #5
New Warrior Member
 
srdjanm's Avatar
 
Join Date: 2018
Location: Belgrade, Serbia
Posts: 4
Thanks: 0
Thanked 3 Times in 2 Posts
Default
RE: Combining the a href + button tag?
Share on: 
fb share twitter share gplus share more share

No, it isn't valid HTML5 according to the HTML5 Spec Document from W3C:

In other words, you can nest any elements inside an <a> except the following:
Code:
<a>
<audio> (if the controls attribute is present)
<button>
<details>
<embed>
<iframe>
<img> (if the usemap attribute is present)
<input> (if the type attribute is not in the hidden state)
<keygen>
<label>
<menu> (if the type attribute is in the toolbar state)
<object> (if the usemap attribute is present)
<select>
<textarea>
<video> (if the controls attribute is present)

If you are trying to have a button that links to somewhere, wrap that button inside a <form> tag as such:

Code:
<form style="display: inline" action="http://example.com/" method="get">
  <button>Visit Website</button>
</form>
However, if your <button> tag is styled using CSS and doesn't look like the system's widget... Do yourself a favor, create a new class for your <a> tag and style it the same way.
srdjanm is offline   Reply With Quote
The Following User Says Thank You to srdjanm For This Useful Post:
Unread 15th Aug 2018, 04:05 AM   #6
New Warrior Member
 
Jari Niemi's Avatar
 
Join Date: 2017
Posts: 1
Thanks: 0
Thanked 2 Times in 1 Post
Default
Re: Combining the a href + button tag?
Share on: 
fb share twitter share gplus share more share

Originally Posted by dansbanners View Post

Would it cause any problems in the website or any browers?

<a href="whatever.html'><button>text in here</button></a>

Is there a better alternative? Thanks.
Button sample:

https://superdevresources.com/super-...st-button-css/
Jari Niemi is offline   Reply With Quote
The Following 2 Users Say Thank You to Jari Niemi For This Useful Post:
Unread 16th Aug 2018, 06:19 PM   #7
ANJAN KUMAR DHALI
 
ANJANBD's Avatar
 
Join Date: 2014
Location: Bangladesh
Posts: 73
Thanks: 3
Thanked 18 Times in 12 Posts
Default
Re: Combining the a href + button tag?
Share on: 
fb share twitter share gplus share more share

<a class="button" href="#">This is Button</a>
<style>
.button{
padding:5px;
background:black;
color:white;
border-radius:5px;
}
a{
text-decoration:none;
}
</style>

ANJANBD is offline   Reply With Quote
The Following User Says Thank You to ANJANBD For This Useful Post:
Unread 28th Sep 2018, 04:30 AM   #8
New Warrior Member
 
swati tiwari's Avatar
 
Join Date: 2018
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Default
RE: Combining the a href + button tag?
Share on: 
fb share twitter share gplus share more share

There is no alternate tag for <a> in HTML. But you can create it's alternative using JavaScript.

It is way less efficient than <a> tag. But if you still want to do it, follow me.

HTML:

<body>
<p class="para">
<span id="redirect">
</span>
</p>

CSS:

.para {
font-family: sans-serif;
color: #F00;
font-size: 127%;
text-decoration: none;
}
#redirect {
font-family: inherit;
color: #0F0;
text-decoration: underline;
}
JavaScript:

document.getElementById("redirect").onclick(redire ct());
function redirect() {
window.location.href="whatever.html";
//May load a cached page
};
swati tiwari is offline   Reply With Quote
The Following User Says Thank You to swati tiwari For This Useful Post:
Unread 30th Sep 2018, 09:35 AM   #9
Active Warrior
 
Join Date: 2009
Posts: 95
Thanks: 111
Thanked 8 Times in 7 Posts
Default
Re: Combining the a href + button tag?
Share on: 
fb share twitter share gplus share more share

Originally Posted by swati tiwari View Post

There is no alternate tag for <a> in HTML. But you can create it's alternative using JavaScript.

It is way less efficient than <a> tag. But if you still want to do it, follow me.

HTML:

<body>
<p class="para">
<span id="redirect">
</span>
</p>

CSS:

.para {
font-family: sans-serif;
color: #F00;
font-size: 127%;
text-decoration: none;
}
#redirect {
font-family: inherit;
color: #0F0;
text-decoration: underline;
}
JavaScript:

document.getElementById("redirect").onclick(redire ct());
function redirect() {
window.location.href="whatever.html";
//May load a cached page
};
Yes. That's another way to do it. I settled on <a class="button"...> and CSS. Thanks.

dansbanners is offline   Reply With Quote
Unread 6th Oct 2018, 01:18 PM   #10
New Warrior Member
 
Marek Anral's Avatar
 
Join Date: 2018
Posts: 5
Thanks: 0
Thanked 2 Times in 2 Posts
Default
RE: Combining the a href + button tag?
Share on: 
fb share twitter share gplus share more share

Add "display:block;" to "button" class, then whole button will be clickable.
Marek Anral is offline   Reply With Quote
The Following User Says Thank You to Marek Anral For This Useful Post:
Unread 4th Apr 2019, 10:58 PM   #11
New Warrior Member
 
Join Date: 2019
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Default
RE: Combining the a href + button tag?
Share on: 
fb share twitter share gplus share more share

<input type="button" class="btn btn-info" value="Input Button" onclick=" relocate_home()">

<script>
function relocate_home()
{
location.href = "www.yoursite.com";
}
</script>
shraddha patel is offline   Reply With Quote
The Following User Says Thank You to shraddha patel For This Useful Post:


Bookmarks

Tags
button, combining, href, tag


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 02:16 AM.