You may need to elaborate on what you are trying to do as the code above just looks like you are linking to another page?
e.g.
<a href="home.htm"><span>Why Me?</span></a>
Is that link taking you to a new page or do you have some js that opens an html/css tab for you in the same page? I mean is it something like this:
Clicking on the top level opens a tab underneath. If so then you need to use a script as in that demo (or maybe the checkbox hack or :target for a non js version although that complicates the html a lot).
Or do you have another purpose in mind?
If you are navigating to a completely new page then you would add a new class in that new page to highlight the menu item using some custom css (basically mimicking your hover styles in the new class).
(Note: I’ve used active for the classname but don’t confuse that with. the css pseudo-class :active which is just the state when an element is clicked and then disappears when released.)
PaulOB, thanks for the quick response.
Yes, I’m just trying to switch to another page.
I have added a new class as per your e.g. and mimicked the hover styles in the CSS but, alas, does not seem to make a difference. The tab does not stay highlighted.
I think we may be talking at cross purposes as I’m still not clear on your process.
At the moment you have two links that link to different pages. If you click a link you go to a different page.
I was assuming that when you arrived on that page you wanted the menu item for that page to be highlighted. If so you would add a new class as I suggested and style it as you wish. There should be no problem with this as long as you follow the rules of specificity.
Or do you mean that before the new page loads the link that you just clicked stays highlighted until the new page loads? Which may be almost instant for a light page.
If that’s what you meant then you may be talking about the :focus pseudo class which will stay focused until the focus is moved elsewhere or the new page loads on top.
Or was there something else you wanted that I misunderstood?
Ok, maybe I did not explain myself correctly, probably comes with age (I am 78).
I have 7 tabs (just did show 2 of them) for 7 web pages. When I switch from one to another, I’d like to have that active tab stay highlighted with the hovering color (it’s actually a 2-part gif) until I switch to the next page. Site visitors should know on which of the 7 pages they are. Does that explain things better?
PaulOB,
As per your advice, I have created a new class but, alas, it does not work. I’m sure I have screwed up things. Could you please skim over the code/
Thanks,
Ed
There is not a pseudo class called tabson! You had this:
#tabs a:tabson
It should be:
#tabs a.tabson
I’m. not sure why you repeated everything again though as you only need to copy the hover styles if you want the active tab to look the same as a hover.
You only need to add the new rule to the existing hover rules.
That will style the hover and the tabson class at the same time. If you wanted the active different from the hover then you would separate those rules and do them individually with their different styles. However theres no need if you want them both to be the same.
If that relates to the tabs (although it doesn’t seem to have any of those ids) then that code will win out as it uses IDs which have higher specificity.
You need to put code inside 3 back ticks at each end of the code or use the code formatting icon in the top of the editor panel </>
PaulOB, it works now, thank you very much.
That odd CSS code was a remnant from a previous, unsuccessful attempt, it’s been removed.
Again, thank you very much for your help, it’s much appreciated.
Ed
I have another question: Your last change made the whole thing work, but it also increased the font size considerably and I don’t know how. I need to add another tab but that would work only with a smaller tab font. I did try to alter all font occurrences in the style sheet but no dice. What would decrease the font size after your last change?
Thanks,
Ed