PDA

View Full Version : Resolved Link color in specified Div



Haroldm814
Jul 28th, 2010, 04:21 PM
Hey everyone, I'm new to css and still a novice to html but I'm stumped as to what I'm doing wrong.

In my HTML page I have 2 divs called main & content. The content div sits inside the main div and the only purpose it serves is to move the text 5px to the right to make it more aesthetically pleasing, but anyway...

I want the links inside the main & content div's to always be blue, #336699.

Now in my CSS sheet, I have a section devoted to the main and content divs as well as my sidebar.

The sidebar looks like this:

ul.navbar a {
text-decoration: none }
a:active {
color: #369; }
a:link {
color: #000; }
a:visited {
color: #000; }
a:hover {
color: #369;
}

and the main and content divs look like this:

#main a {
text-decoration: none }
a:active {
color: #369; }
a:link {
color: #369; }
a:visited {
color: #369; }
a:hover {
color: #369;
}

Now when I put the #main code in my CSS sheet every link turns blue including my side nav. I want the side nav to have all black links except for the current link which I want the same color blue. Now the side nav works perfect now if the #main code is left out.

I'm stumped because I have the <div></div> tags set correctly in my html doc and the side nav looks how I want when the #main code is left out.

Any ideas?

abduraooft
Jul 28th, 2010, 04:32 PM
ul.navbar a {
text-decoration: none }
a:active {
color: #369; }
a:link {
color: #000; }
a:visited {
color: #000; }
a:hover {
color: #369;
} You need to make it specific for the other selectors too, like

ul.navbar a {
text-decoration: none }
ul.navbar a:link {
color: #000; }
ul.navbar a:visited {
color: #000; }
ul.navbar a:hover {
color: #369;
}
ul.navbar a:active {
color: #369; } Similarly for the next set.

PS: IE may show some bugs if the order of link pseudo classes is not like link,visited,hover,active (ie. LoVe-HAte) See http://www.w3schools.com/CSS/css_pseudo_classes.asp

Haroldm814
Jul 28th, 2010, 04:58 PM
Gahh thanks abduraooft,

I knew it had to be something simple and stupid haha.

Thanks for the help, I'm slowly learning more and more everyday. :p