2

I have a "migrated.html" page in root directory. How do I add that link to this CSS style button?

<button onclick="#" <a href="migrated.html" class="glossy-button glossy-button--red"></a>Migrated</button>

The above html code didn't work for me.

Here is the link to the code set:

https://codepen.io/prateek-vishwas/pen/Rwwpzjo

2 Answers 2

1

There are a few different ways to accomplish this.

But, from what I understand, it sounds like you just want an anchor <a> tag with a href attribute that is styled like this button.

You can simply just set the same class on the anchor tag that is on the button, so you should receive

<a href = "url-to-ur-page" class = glossy-button glossy-button--red>Migrated</a>

Sign up to request clarification or add additional context in comments.

Comments

0

Why it has to be a button ? Why not use the normal "A" tag and style him like a button ?

<a href="migrated.html" class="glossy-button glossy-button--red">!!!Migrated!!! 
</a>

Works in your codepen - ijust moved the migrated text inside the tag

This will work even without javascript. Anyhow.the js to change the current url is

window.location = 'your url';

  <button onclick="window.location='migrated.html';"> 
   <a href="migrated.html" class="glossy-button glossy-button--red"></a>
   Migrated
   </button>

which also work in your pen

3 Comments

First solution worked perfectly for me. I have just started learning css 3 days ago. Still a lot to learn. Thank you for your help @thomas
Thomas Is it possible to remove underline from the button text/ hyperlink?
Yes it is :) With CSS -> a{text-decoration:none;} will do this tiny trick :) Keep on lerning :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.