views:

91

answers:

5

i have this li list , but i want to know how to have the current page link have a background of white,(li:active)

css:

#layout-three-liquid2 #section-navigation ul
{
    margin: 0;
    padding: 0;
}

#layout-three-liquid2 #section-navigation ul li
{
    margin: 0 0 0em;
    padding: 0;
    list-style-type: none;
}
#layout-three-liquid2 #section-navigation ul li:hover{

    background-color:white;



}
#layout-three-liquid2 #section-navigation ul li a:active{

    background-color:white;



}

html:

<ul>
   <li><a active="current" href="#page1">Home</a></li>
   <li><a href="#page3">Replies</a></li>
</ul>

but its not working, how can i solve this?

+4  A: 

Your code li:active isn't valid/correct. You need to specify a class and the link in your CSS like this:

#section-navigation ul li a.current {
  background-color:white;
}
Sarfraz
this deos not work, updated css code, to show you the whole ul css class
getaway
@getaway: Updated according to your code/css.
Sarfraz
@sarfaz this works thanks, but it highlights only the link, i need to highlight the whole li! it looks so ugly lol :)) +1 upvote from me
getaway
@getaway: Good news. For li you need to use the same class at li not link and use li.current in css instead.
Sarfraz
@sarfraz amazing thank you:))
getaway
+1  A: 

You can't do <a active="current">

because active isn't a valid attribute of the <a> element.

try using class=current instead.

then in your css you can target the element with

#layout-three-liquid2 #section-navigation ul li a.current {
    ...
}
jordanstephens
+1  A: 

You're abusing CSS pseudo-classes. :active and :hover are special values, those are used when the link is clicked (has the focus) and when the user moves the mouse pointer above it.

CSS classes should be used instead:
CSS:

#layout-three-liquid2 #section-navigation ul li a.current{

    background-color:white;
}

HTML:

<ul>
   <li><a class="current" href="#page1">Home</a></li>
   <li><a href="#page3">Replies</a></li>
</ul>
Lekensteyn
this is not working sorry
getaway
A: 

Here is a link to an article which explains how to implement this.

http://hicksdesign.co.uk/journal/highlighting-current-page-with-css

hope this helps.

Roger
A: 

Note that :active doesnt mean the page you are currently on, it just means that the link is being clicked. (It might works in framesets also)

You have to do some server side scripting to set the class to link_active or something like that.

Rabarber