Solved

Make current menu a certain color

Posted on 2014-10-15
10
122 Views
Last Modified: 2014-10-16
I am trying to make the current menu a certain color.  It's not working.
The HTML
<ul>
   <li class="current"><a href='#'><span>Home</span></a></li>
   <li><a href='#'><span>About</span></a></li>
   <li class='active has-sub'><a href='#'><span>Services</span></a>
      <ul>
         <li><a href='#'><span>Reputation Cleaner</span></a></li>
         <li><a href='#'><span>Search Engine Optimization</span></a></li>
         <li><a href='#'><span>Account Eraser</span></a></li>
      </ul>
   </li>

Open in new window


The CSS
.ul.menu li.current a {
	color:#f8fb04;
	}

Open in new window

0
Comment
Question by:DS928
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
10 Comments
 
LVL 27

Expert Comment

by:Dr. Klahn
ID: 40383689
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
<style>
	.current {
	background-color: #f8fb04;
	}
</style>
</head>

<body>

<ul>
   <li class="current"><a href='#'><span>Home</span></a></li>
   <li><a href='#'><span>About</span></a></li>
   <li class='active has-sub'><a href='#'><span>Services</span></a>
      <ul>
         <li><a href='#'><span>Reputation Cleaner</span></a></li>
         <li><a href='#'><span>Search Engine Optimization</span></a></li>
         <li><a href='#'><span>Account Eraser</span></a></li>
      </ul>
   </li>

</body>
</html>

Open in new window


Note that if you want the whole list to have the style and not just the individual list element, the style must be applied in the UL tag instead:

<ul class="current">

Open in new window

0
 

Author Comment

by:DS928
ID: 40383700
I just want the word home to be the different color.  I tried this but it still doesn't change the color.

.current {
	color: #f8fb04;
	}

Open in new window

and this
.current {
	background-color: #f8fb04;
	}

Open in new window

0
 
LVL 27

Expert Comment

by:Dr. Klahn
ID: 40383712
An easier way to do it than by applying a style:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
</head>

<body>

<ul>
   <li><a href='#'><span><FONT COLOR="#F8FB04">Home</FONT></span></a></li>
   <li><a href='#'><span>About</span></a></li>
   <li class='active has-sub'><a href='#'><span>Services</span></a>
      <ul>
         <li><a href='#'><span>Reputation Cleaner</span></a></li>
         <li><a href='#'><span>Search Engine Optimization</span></a></li>
         <li><a href='#'><span>Account Eraser</span></a></li>
      </ul>
   </li>

</body>
</html>

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 58

Expert Comment

by:Gary
ID: 40384445
God don't use FONT

http://jsfiddle.net/v3enLqyn/

Your menu, with a class added to the top menu
<ul class="menu">
   <li class="current"><a href='#'><span>Home</span></a></li>
   <li><a href='#'><span>About</span></a></li>
   <li class='active has-sub'><a href='#'><span>Services</span></a>
      <ul>
         <li><a href='#'><span>Reputation Cleaner</span></a></li>
         <li><a href='#'><span>Search Engine Optimization</span></a></li>
         <li><a href='#'><span>Account Eraser</span></a></li>
      </ul>
   </li>
</ul>

Open in new window


CSS
ul.menu li.current a {
	color:#f8fb04;
}

Open in new window

0
 

Author Comment

by:DS928
ID: 40384496
Yes.  I noticed that FONT changed the color but moved everything around as well.
Here is the HTML
<ul class="menu">
   <li class="current"><a href='#'><span>Home</span></a></li>
   <li><a href='#'><span>About</span></a></li>
   <li class='active has-sub'><a href='#'><span>Services</span></a>
      <ul>
         <li><a href='#'><span>Reputation Cleaner</span></a></li>
         <li><a href='#'><span>Search Engine Optimization</span></a></li>
         <li><a href='#'><span>Account Eraser</span></a></li>
      </ul>
   </li>

Open in new window


The CSS
.ul.menu li.current a {
	color:#f8fb04;
}

Open in new window


Still not changing the word "Home" to yellow.
0
 
LVL 58

Expert Comment

by:Gary
ID: 40384516
You're not using the correct css

ul.menu li.current a {
	color:#f8fb04;
}

Open in new window

0
 

Author Comment

by:DS928
ID: 40384535
i tried that as well. Still not changing the color.

http://www.davidschure.com/index.html

<div id="container">
 <div id='cssmenu'>
   <ul class="menu">
   <li class="current"><a href='#'><span>Home</span></a></li>
   <li><a href='#'><span>About</span></a></li>
   <li class='active has-sub'><a href='#'><span>Services</span></a>
      <ul>
         <li><a href='#'><span>Reputation Cleaner</span></a></li>
         <li><a href='#'><span>Search Engine Optimization</span></a></li>
         <li><a href='#'><span>Account Eraser</span></a></li>
      </ul>
   </li>
   <li><a href='#'><span>Corporate</span></a></li>
   <li><a href='#'><span>Estate Eraser</span></a></li>
   <li class='active has-sub'><a href='#'><span>Contact / Info</span></a>
      <ul>
         <li><a href='#'><span>Contact Us</span></a></li>
         <li><a href='#'><span>Terms and Conditions</span></a></li>
         <li><a href='#'><span>Privacy Policy</span></a></li>
   	  </ul>
</li>
 </div>

Open in new window

0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40384552
#cssmenu > ul > li.current > a {
    color: #f8fb04;
}

Open in new window

0
 

Author Comment

by:DS928
ID: 40384683
Bingo!  That worked!  Why?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40384684
It's more specific targetting, since you are using that to set the default colour you have to use the same targetting to change a color on a specific item
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question