Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

CSS nav text colour help

Featured Replies

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!

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.

  • 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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.