Samuel Felicio
Samuel Felicio

Reputation: 9

How can I make an <li> change color when it's clicked and stay with that color until a redirect?

How can I make an <li> in a navigation menu change color after clicking it and stay with that color as long as it's on that same page of my website, preferably without using JavaScript or jQuery? Thanks.

Example: https://smartsoftcode.com/preview/kenox/demo/index-v2.html
Each item in the navigation menu at the top changes color when it's clicked and stays with that color until another list item is clicked.

Upvotes: -1

Views: 1438

Answers (1)

SHUBHAM LONGIA
SHUBHAM LONGIA

Reputation: 1

Try this active method:

<!DOCTYPE html>
<html>
<head>
<style>
.active:active {
  color: red;
}
.focus:focus {
  color: red;
}
:target {
  color: red;
}
</style>
<body>
<a href='#target1' id='target1' class='target'>Target 1</a>
<a href='#target2' id='target2' class='target'>Target 2</a>
<a href='#target3' id='target3' class='target'>Target 3</a>

</body>
</html>

Upvotes: 0

Related Questions