0

I have the following Javascript in order to create a back button to the previous page.

<script>// <![CDATA[
function goBack() { window.history.back() }
// ]]></script>
<button onclick="goBack()">Go Back</button>

I want to style my button by changing the background colour and text colour. However, I am not very experienced. I have searched but cannot find out if this is even a possibility.

A. Matulewicz
  • 25
  • 3
  • 8

1 Answers1

1

You need to use Class to achieve what you are looking for.

After using class, you need to style it to add background, padding, etc. For instance,

.buttonBg {
  background-color: #4CAF50;
  /* Green */
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  cursor: pointer;
}
<button onclick="goBack()" class="buttonBg">Go Back</button>

Live demo

Hope this helps.

mplungjan
  • 169,008
  • 28
  • 173
  • 236
Nitesh
  • 15,425
  • 4
  • 48
  • 60