470,613 Members | 1,765 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,613 developers. It's quick & easy.

ID Selector problem

Hi,
I am having some grieve with the following part of my CSS, basically
when using a composite selector using an ID as the first element the
it doesn't display the expected results. Am I doing something
incorrect? For example my CSS goes something like this:

#leftnavbar a:link {
color: #333;
text-decoration: none;
}
#leftnavbar a:visited {
color: #FFF;
}

#topnavbar a:link {
color: #000;
}
#topnavbar a:visited {
color: #FFF;
}

However, for some reason both within dreamweaver and Explorer all the
links are using the #topnavbar colours? i.e. the #topnavbar selector
is overriding the #leftnavbar selector, even standard links in the
general "body" of the document are being changed to the #topnavbar
colours when they should stay as links normally would. What am I doing
wrong?

Thanks

Zane
Jul 20 '05 #1
4 2675
Zane wrote:
#leftnavbar a:link {
color: #333;
text-decoration: none;
}
#leftnavbar a:visited {
color: #FFF;
}

#topnavbar a:link {
color: #000;
}
#topnavbar a:visited {
color: #FFF;
}

However, for some reason both within dreamweaver and Explorer all the
links are using the #topnavbar colours? i.e. the #topnavbar selector
is overriding the #leftnavbar selector, even standard links in the
general "body" of the document are being changed to the #topnavbar
colours when they should stay as links normally would. What am I doing
wrong?


The CSS looks OK. So either you are hallucinating, or there's a problem
that is not apparent from your code snippet, either in your HTML code or
the stylesheet. Give us the URL so we can see the whole thing in context!
Matthias

Jul 20 '05 #2
za*********@hotmail.com (Zane) wrote:
#leftnavbar a:link {
color: #333;
text-decoration: none;
}
#leftnavbar a:visited {
color: #FFF;
}

#topnavbar a:link {
color: #000;
}
#topnavbar a:visited {
color: #FFF;
}

However, for some reason both within dreamweaver and Explorer all the
links are using the #topnavbar colours? i.e. the #topnavbar selector
is overriding the #leftnavbar selector, even standard links in the
general "body" of the document are being changed to the #topnavbar
colours when they should stay as links normally would. What am I doing
wrong?


The CSS looks okay, (though you really should set a background colour
whenever you set a foreground colour). So the problem is probably with
the HTML. Post a URL.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #3
Zane wrote:
Hi,
I am having some grieve with the following part of my CSS, basically
when using a composite selector using an ID as the first element the
it doesn't display the expected results. Am I doing something
incorrect? For example my CSS goes something like this:

#leftnavbar a:link {
color: #333;
text-decoration: none;
} [snip] However, for some reason both within dreamweaver and Explorer all the
links are using the #topnavbar colours? i.e. the #topnavbar selector
is overriding the #leftnavbar selector, even standard links in the
general "body" of the document are being changed to the #topnavbar
colours when they should stay as links normally would. What am I doing
wrong?


There's nothing obviously wrong. I suspect there's a problem with your HTML
(perhaps you aren't closing the #topnavbar element in the right place?).
Validate your HTML and if you still have trouble, give a URL to a testcase.
--
Jim Dabell

Jul 20 '05 #4
Zane wrote on 13 aug 2003 in comp.infosystems.www.authoring.stylesheets:
However, for some reason both within dreamweaver and Explorer all the
links are using the #topnavbar colours? i.e. the #topnavbar selector
is overriding the #leftnavbar selector, even standard links in the
general "body" of the document are being changed to the #topnavbar
colours when they should stay as links normally would. What am I doing
wrong?


There is a difference between:

#topnavbar a:hover { color: #0f0; }

and

a#topnavbar:hover { color: #0f0; }

the first <a > expects a parent with the id topnavbar

<div id=topnavbar><a href=''>...

the second <a > expects to be the owner of the id topnavbar

<a id=topnavbar href=''>...

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Lian Liming | last post: by
2 posts views Thread by tagbert | last post: by
25 posts views Thread by Tim & Alethea Larson | last post: by
1 post views Thread by John Rowe | last post: by
2 posts views Thread by Chris Sharman | last post: by
8 posts views Thread by sajid | last post: by
1 post views Thread by jorgedec | last post: by
6 posts views Thread by _googlepost | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.