Skip to content
← Back to Community
Code not working. Please help
Profile icon
DreamyStars

In the file contact.html i put a button link called go back to main page and gave the link as index.html:

<button class="GFG" onclick="window.location.href = 'index.html';"> Go Back to main page </button>

This is the code but it is not working.
Please help

Answered by codingjlu [earned 5 cycles]
View Answer
Voters
Profile icon
Manoj003
Profile icon
DreamyStars
Comments
hotnewtop
Profile icon
codingjlu

Don't do a button; use a link - you can style one to look like a button, something like this CSS:

#btn { text-decoration: none; padding: 5px 10px; background-color: #4287f5; color: white; outline: none; border: none; border-radius: 5px; }
<a id="btn" href="/index.html">Hello world!</a>

Result:

image

You just got a nice looking "button". Also, this is the correct/traditional way to do it. An actual button would not let you open in a new tab, and it doesn't act as a link, and it breaks the back button.

Profile icon
DreamyStars

@codingjlu Thank you so much for the help.(¬‿¬)

Profile icon
codingjlu
Profile icon
FishballNooodle

Sure about this
But you can create an [ tag and remove the text decorations, add border and it will look like a button.
Then you can use href="index.html"]

Profile icon
DreamyStars

sure will try @FishballNooodle

Profile icon
FishballNooodle

@Satkrithi
text-decorations:None
border : 10 5 10 5
border-radius: 10px

Profile icon
DreamyStars

@FishballNooodle are you sure? I have tried doing it but it is still not working

Profile icon
Coder100

It is not working because some of your pages don't have any code.
For example, Thank you contact.html and Topics.html.

Profile icon
DreamyStars

@Coder100 In that case, it would show blank page but here it is showing page not found.