0

I am in a web page:

http://localhost:3000/

In this page I have a link:

<a href="/dynamic-username/boards">user's boards</a>

in this page I doing click in above link and I go to this page:

http://localhost:3000/dynamic-username/boards

Dynamic username is the username for each user.

I want to apply a css style to the link, if I am visiting this last page. If I visit this page of any user.

How can I apply the css style after I go to second page?

This link is shared for every views in my framework and I have the same css for all views.

I want that if detect this url apply to this link a style css with

font-weight:bold
3
  • add <link rel="stylesheet" href="/url/style.css"> to the <head> of the document? Commented Feb 29, 2012 at 18:44
  • I don't understand the question. Can you please re-vise? Commented Feb 29, 2012 at 18:45
  • Can you please explain your problem better. I am sorry but unable to understand what you want to accomplish. Commented Feb 29, 2012 at 18:45

3 Answers 3

1

I believe what you're after is the :visited pseudo selector of the link:

 /* Unvisited links will be normal font weight */
 a:link{
   font-weight: normal;
 }

 /* Link will be bold after user has visited it */
 a:visited{
   font-weight: bold;
 }

This will change the appearance of any links on the user's board page that you've already been to.

Sign up to request clarification or add additional context in comments.

Comments

0

Add a second stylesheet or inline style on the destination page that will override the styles for that link. No javascript necessary

Comments

0

You can parse the url and compare to href of the link with javascript but it would be cleaner to simply add a "current_page" class in your server code and generate a css rule for that link class

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.