SITERAW

Button with link not working

Author Message
Kleader # Posted two weeks ago
A form button with a href not opening Hi

I don't know what's the problem with my button but the link isn't working properly.
<a href="siteraw.html"><button id="bt"></button></a>
Any help is appreciated.
Ads
Bougnoulz # Posted one week ago
Bougnoulz I tested your code, it works.
Do you get an error message?
What browser are you using?
Kleader # Posted yesterday
Kleader Google Chrome but I also tried with Internet Explorer and I get the same problem.
Kim Jong Un # Posted yesterday
Kim Jong Un Hello,

the <button> element cannot be nested within a <a>.

Why do you need to do that anyway?

Just apply CSS (via the bt class I suppose?) directly to the link.

You might have to change the display to block as <a> is inline by default.
Demand3d # Posted two hours ago
Demand3d Strange as it works under Linux (Debian) with Firefox, Chrome, Opera and even the internal browser of Komodo-edit.

With that said, Kim Jong Un's remark is very pertinent.
Kegon # Posted one hour ago
Kegon It's not because it "works" on some browsers (more permissive on the syntax), that it is valid and thus compatible.
Celeri # Posted 37 minutes ago
Celeri The documentation is pretty clear on this matter.
The Anchor element

Permitted parents: Any element that accepts phrasing content, or any element that accepts flow content.
You can still do the opposite since <button> allows the inclusion of HTML content (it's why the tag was created after all).
<button class="bt">

<a
href="siteraw.html">Link</a>

</button>
Kleader # Posted 5 minutes ago
Kleader Thanks! I'll try that method.

Post a reply