By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,508 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,508 IT Pros & Developers. It's quick & easy.

ID Selector problem

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.