6 replies [Last post]
fatfreddy
fatfreddy's picture
Offline
Enthusiast
Deep down under
Last seen: 14 years 10 weeks ago
Deep down under
Timezone: GMT+8
Joined: 2005-03-25
Posts: 390
Points: 0

I'm sure it's something silly but i am trying to get my current page link to be highlighted

ie. i'm on the hime page so the homepage link should be highlighted.
I am using a:active but do not get any result.
[edit] just realised that a:active isn't going to do it so have tried a:focus but still with no result - i may be stupid but im still stuck?[/edit]

I have done a search on here and it should work.
I've tried in IE and Firefox!!!!

Help!!!!

http://members.westnet.com.au/freakmansion/testsites/seaeco/index.htm

The only reason for time is so that everything doesn't happen at once
--Albert Einstein

Accessible webdesign Australia - webechodesigns

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 30 weeks 9 hours ago
Dallas
Timezone: GMT-6
Joined: 2004-06-25
Posts: 9776
Points: 3858

active link problem

My method is simplicity its own self. Give each <li> an id. Make it simply the name of the page, or its filename. I use server side includes, so this is a one-time deal.

My usual thing is to cause that menu item to disappear, but you could give it any rules you like. In the page head, as the last style rule do something like this;

For the home page,

#home {
    display: none;
    }
You might prefer
#home a {
    color: yellow;
    background-color: green;
    border: 5px ridged #fee;
    }

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

fatfreddy
fatfreddy's picture
Offline
Enthusiast
Deep down under
Last seen: 14 years 10 weeks ago
Deep down under
Timezone: GMT+8
Joined: 2005-03-25
Posts: 390
Points: 0

active link problem

nice one gary

I had done something like this before but thought you should just be able to do it through the active or fcus etc.

Back to this method i guess

cheers

Freddy

The only reason for time is so that everything doesn't happen at once
--Albert Einstein

Accessible webdesign Australia - webechodesigns

briski
briski's picture
Offline
Elder
London
Last seen: 9 years 15 weeks ago
London
Timezone: GMT+1
Joined: 2004-02-16
Posts: 1066
Points: 0

active link problem

Just to explain why active and focus does not work in the way you imagined they would.

When a link is in the focus state this means that on the page you are on this is the element that has focus - ie when you tab to something it has focus. For links focus should be given the same properties as hover in my opinion so what people using keyboards get the same highlighting as mouse users get when they hover.

The active state is when the link is in the process of being clicked and lasts not a great deal of time at all.

Directly from the w3c CSS spec

# The :hover pseudo-class applies while the user designates an element (with some pointing device), but does not activate it. For example, a visual user agent could apply this pseudo-class when the cursor (mouse pointer) hovers over a box generated by the element. User agents not supporting interactive media do not have to support this pseudo-class. Some conforming user agents supporting interactive media may not be able to support this pseudo-class (e.g., a pen device).
# The :active pseudo-class applies while an element is being activated by the user. For example, between the times the user presses the mouse button and releases it.
# The :focus pseudo-class applies while an element has the focus (accepts keyboard events or other forms of text input).

fatfreddy
fatfreddy's picture
Offline
Enthusiast
Deep down under
Last seen: 14 years 10 weeks ago
Deep down under
Timezone: GMT+8
Joined: 2005-03-25
Posts: 390
Points: 0

active link problem

Cheers Briski

That does clear it up (and makes me realise that the 45 mins i spent d&*king around trying to get it to work was a waste) :oops:

Still - always learning eh?

The only reason for time is so that everything doesn't happen at once
--Albert Einstein

Accessible webdesign Australia - webechodesigns

sergei
Offline
newbie
USA
Last seen: 13 years 5 weeks ago
USA
Joined: 2008-08-20
Posts: 1
Points: 0

:focus

Briski -thank you for a thorough explanation. CSS was intended to deal with appearances and not user generated events. Yet there are compelling reasons to build websites as pure CSS without the use of scripting languages such as JavaScript. Security is the most important one. If only CSS would allow to change appearances of elements on mouse click, it would be possible to use simple, robust methods and achieve desired results. Opera 9+ and Firefox 3+ allow that even it is not strictly the specs. But Safari 3+ does not. I would argue that some form of "onclick" pseudo class that changes style or at least visibility of other elements should be included into CSS standards.

Ed Seedhouse
Ed Seedhouse's picture
Offline
Guru
Victoria British Columbia
Last seen: 31 weeks 6 days ago
Victoria British Columbia
Timezone: GMT-8
Joined: 2005-12-14
Posts: 3570
Points: 675

sergei wrote:Briski -thank

sergei wrote:

Briski -thank you for a thorough explanation. CSS was intended to deal with appearances and not user generated events. Yet there are compelling reasons to build websites as pure CSS without the use of scripting languages such as JavaScript. Security is the most important one. If only CSS would allow to change appearances of elements on mouse click, it would be possible to use simple, robust methods and achieve desired results.

CSS does not "allow" anything. CSS is only a specification. It has to be implemented by the browser programmers, and like javascript or anything else, it may be implemented well or badly.

Right now we can't even get browser creators to implement the current standard the same way from browser to browser. Complicating the specification will likely only lead to poorer implementations and even less security.

Ed Seedhouse

Posting Guidelines

Watch out! I am carrying irony, sarcasm and satire, and know how to use them.