2 replies [Last post]
warmpepsi
Offline
newbie
Last seen: 12 years 28 weeks ago
Joined: 2008-03-13
Posts: 1
Points: 0

I have a menu that when one tab is selected, it shows a focus state. But when you click on a text field or a link, that focus state goes away from the menu. Is it possible to have the menu item stay focus after is it selected while clicking on another link or text field?

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 10 hours 15 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9767
Points: 3849

Not with css. :focus is the

Not with css. :focus is the state of having focus. Only one element can have focus at a time. The item with focus is the element that can be clicked, take keyboard entry or otherwise be done to.

It would be a Bad Idea® to simulate multiple foci. That would confuse the user. If you want to do it anyway, it will take javascript to alter the DOM. That discussion is beyond the scope of this forum.

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.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 5 years 37 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Me do suspect that this is

Me do suspect that this is actually the oft asked question regarding having an active highlight on a menu/nav link and where people tend to confuse the pseudo class :focus with this requirement.

If the OP wishes to confirm this then a CSS approach can be offered, although searching the forum archives will throw up many past posts where this is explained in detail.

Best approach to achieving this is through server side scripting though.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me