Sorry if this sounds like a really stupid question, but I need to make a link change colour when you are on the page it links to.
For example, when you are on the "Questions" page of StackOverflow, the link at the top changes colour. How do you do this?
If you want to highlight the "current" menu entry, you have to make it discernible to CSS by making it special in the HTML code - for example by adding a class "active" or "current".
To change the color of links in HTML, use the CSS property color. Use it with the style attribute. The style attribute specifies an inline style for an element. Use the style attribute with the CSS property color to change the link color.
It really depends on how your page is constructed. Typically, I would do this using CSS, and assign give the link an id called "active"...
<a id="active" href="thisPage.html">this page</a>
...and in the CSS...
a#active { color: yellow; }
Obviously this is a fairly simplistic example, but it illustrates the general idea.
It's a server-side thing -- when rendering the page, add a class like "current-page" to the link. Then you can style it separately from the other links.
For example, StackOverflow renders the links with class="youarehere"
when it points to the page you're already on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With