Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Active Links - CSS

Featured Replies

I'm possibly being quite dumb here but I have the following problem I'm hoping you can help me with.

 

I have a menu built in CSS with link, hover, visited, etc. Am I right in assuming the 'active' link will control the appearance of a link when a visitor is on that particular page?

 

For example, the menu is in a blue font and when the visitor goes to the 'about us' page, I can set the link in the menu for 'contact us' to turn red using the active element in CSS?

 

I have tried to use the 'active' element but it doesn't change the link colour for an 'active' page. Am I misinterpreting the use of the 'active' element and if so, how do I achieve the effect of having the current page link highlighted in a different colour?

 

Thanks in advance.

Active means when the user has clicked on the link.

 

Don't forget that in your CSS it needs to be in the following order:

 

a:link{ }
a:visited { }
a:hover{ }
a:active { }

 

Take a look at the W3Schools website for more information.

Also - if you want an OnPage type of link you can use

 

a.onpage { }

 

and then in your html use

 

<a href="#" class="onpage">Link</href>

Browsers treat the active state differently. Read this:-

http://www.wickham43.net/generaladvice.php#links

 

Most only show the active state while pressing the mouse button, not afterwards, (ie only while it is active) but IE retains the active state after you use the back button to return to the page you clicked on a link.

 

What you want may need is focus to identify the link that is active (to go to) next time you click Enter (useful for disabled people or screen readers), which again is treated differently because IE doesn't support focus, using active instead.

 

Am I right in assuming the 'active' link will control the appearance of a link when a visitor is on that particular page?

 

No. Highlighting the current link to show what page you are on at the time (not the one you will go to next) is something different again.

 

See http://www.wickham43.net/highlighthome.php

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.