February 22, 201016 yr Hi all, I'm new to the whole web design situation and am having trouble with getting my nav colour text to change using CSS. I have the nav bar so that the tab is highlighted for the corresponding page. My problem lies when I try to change the highlighted tab's text colour as it doesn't change. My code is below, hopefully I'm making sense. #nav { height: 40px; background: url(images/navbg.gif) no-repeat; text-align: center; font-size: large; } #nav ul { padding: 0; margin: 0; padding-top: 13px; } #nav li { display: inline; padding-top: 15px; list-style-type: none; } #nav li a { text-decoration: none; padding: 7px 10px; color: #8B2156; } #indexbody #indexnavlink, #combody #comnavlink, #spabody #spanavlink, #aboutbody #aboutnavlink, #featbody #featnavlink, #conbody #connavlink { background-color: #8b2156; padding: 7px 0px; color: #fff; } #nav li a:hover { color: #FFF; background-color: #8B2156; } Appreciate any help! Oh and hi all by the way!
February 23, 201016 yr You have this style:- #indexbody #indexnavlink, #combody #comnavlink, #spabody #spanavlink, #aboutbody #aboutnavlink, #featbody #featnavlink, #conbody #connavlink { background-color: #8b2156; padding: 7px 0px; color: #fff; } Notice the pairs of ids like #indexbody #indexnavlink, separated with a comma. These are the styles for changing the text color for the link for the page you are looking at. The first id should be for the page as a whole, either in the <body id="indexbody"> or for the nav container or the nav ul tag. The second id is in the link code like <li id="indexnavlink"><a href=".......">Link 1</a></li> but I would normally put the "a" after the second id:- #indexbody #indexnavlink a, #combody #comnavlink a, #spabody #spanavlink a, #aboutbody #aboutnavlink a, #featbody #featnavlink a, #conbody #connavlink a { background-color: #8b2156; padding: 7px 0px; color: #fff; } It's difficult to know without seeing the rest of your code. See an example here:- http://www.wickham43.net/highlighthome.php items 2 or 3.
February 23, 201016 yr Author Thanks for your quick reply. As predicted it was a completely rookie mistake on my part, I just forgot to add the a at the end... On the plus side it all works as I want it to now so thanks for the help!
Create an account or sign in to comment