user3376521
user3376521

Reputation: 117

How to give a anchor link the hover style for when it is the selected link

I'm probably not explaining this very well and I know there is a css property that handles this, I just cant remember its name. I have a menu and I want currently selected link that corresponds to the page being viewed be styled in a way that shows the user what page he is on.

Thanks

Upvotes: 0

Views: 64

Answers (1)

Dryden Long
Dryden Long

Reputation: 10182

You can do this by editing the HTML of each page and adding a class to the relevant link. For example, if you are on the index.html page, your markup might look something like this:

<a href="index.html" class="current">Home</a>
<a href="news.html">News</a>
<a href="about.html">About Us</a>

But if you were on the news.html page, it would look something like this:

<a href="index.html">Home</a>
<a href="news.html" class="current">News</a>
<a href="about.html">About Us</a>

Notice how the class is only on the current page. You then style current however you see fit in your CSS file like so:

.current {
   ...
}

Upvotes: 3

Related Questions