473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

CSS selector problem

Hi all. I'm on a WinXP/IE6 machine...

If I have the following markup - basically a vertical menu of links and
sub-links:

....
<body id="tab2">
....
<ul id="site-links">
<li class="link2">
<a href="./aaa/index.htm">AAA</a>
<ul id="sub-links">
<li class="link2-1">
<a href="./aaa/sub1.htm">Sub 1</a>
</li>
<li class="link2-2">
<a href="./aaa/sub2.htm">Sub 2</a>
</li>
...
</ul>
</li>
</ul>

and I want to apply style to the first <A> element - say, bold the link
- without applying that same style to the other <A> elements - the
sub-links - within <li class="link2">, why doesn't this...

body#tab2 li.link2 > a
{
font-weight: bold;
}

work? Meaning, I realize this should bold all the links that are
children of li.link2 - which is not what I want. But it doesn't even do
that. What's wrong? And then, how do I just bold the first link and not
the sub-links?

Thanks,
motivus

Jul 21 '05 #1
8 2253
* motivus wrote in comp.infosystems.www.authoring.stylesheets:
Hi all. I'm on a WinXP/IE6 machine... why doesn't this...

body#tab2 li.link2 > a
{
font-weight: bold;
}

work?


IE6 does not support the child combinator.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Jul 21 '05 #2
Ok. Just investigated. I see...

Either way, anyone know how I can bold just the first <A> element in
that nested <LI> construct?

motivus

Jul 21 '05 #3
in comp.infosystems.www.authoring.stylesheets, motivus wrote:
Ok. Just investigated. I see...

Either way, anyone know how I can bold just the first <A> element in
that nested <LI> construct?


:first-child

IE don't support that either.

li a {stuff:do}
li a a {stuff:undo;}

(learn to quote, please)
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Utrecht, NL.
Support me, buy Opera:
https://secure.bmtmicro.com/opera/bu...tml?AID=882173
Jul 21 '05 #4

Lauri Raittila wrote:
Either way, anyone know how I can bold just the first <A> element in that nested <LI> construct?
:first-child

IE don't support that either.

li a {stuff:do}
li a a {stuff:undo;}


Thanks. Of course I was trying to avoid that. But c'est la vie.
(learn to quote, please)


I'm concerned about Usenet's bandwidth and storage demands.

Jul 21 '05 #5
Ok. I "resolved" that last issue (thanks Lauri!). Now I have a new one.
Again, I'm on a WinXP/IE6 machine...

And again, I'm basically creating a vertical menu of links and
sub-links. The problem is that my style for the first <LI> is being
applied to the second <UL>, which is NOT nested. Here's the markup and
the CSS (modified from earlier!):

....
<body id="tab2">
....
<ul id="site-links">
<li id="link1">...</li>
<li id="link2">
<a href="./bbb/index.htm">BBB</a>
</li>
<ul class="sub-links">
<li id="link2-1">
<a href="./aaa/sub1.htm">Sub 1</a>
</li>
<li id="link2-2">
<a href="./aaa/sub2.htm">Sub 2</a>
</li>
</ul>
<li id="link3">...</li>
<li id="link4">...</li>
</ul>

What I want is a highlighted box to wrap around the first <LI> element,
which contains a link:

body#tab2 li#link2
{
background-color: #fff;
border: 1px solid #6c6;
margin: 0;
padding: .5em 0 .5em 1em;
}

The problem is that this box also wraps around the ul.sub-links
element! I can't figure out why as it is no longer nested within the
first <UL>'s <LI> element.

Any ideas on why this is happening? It doesn't appear that 'body#tab2
li#link2' should reference 'body#tab2 ul.sub-links'

Thanks,
motivus

Jul 21 '05 #6

motivus wrote:
...
<body id="tab2">
...
<ul id="site-links">
<li id="link1">...</li>
<li id="link2">
<a href="./bbb/index.htm">BBB</a>
</li>
<ul class="sub-links">
<li id="link2-1">
<a href="./aaa/sub1.htm">Sub 1</a>
</li>
<li id="link2-2">
<a href="./aaa/sub2.htm">Sub 2</a>
</li>
</ul>
<li id="link3">...</li>
<li id="link4">...</li>
</ul>


Hmm. I'm looking at this and realizing my markup is probably illegal.
It looks like I've got to nest ul.sub-links within ul#site-links. The
question is, how do I prevent the 'body#tab2 li#link2' style from being
applied to ul.sub-links??

motivus

Jul 21 '05 #7
in comp.infosystems.www.authoring.stylesheets, motivus wrote:
The problem is that my style for the first <LI> is being
applied to the second <UL>, which is NOT nested.


[code snipped]

URL?
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Utrecht, NL.
Support me, buy Opera:
https://secure.bmtmicro.com/opera/buy-opera.html?AID=882173
Jul 21 '05 #8

Lauri Raittila wrote:
[code snipped]

URL?


Unfortunately, I don't have a URL at this time. I'm prototyping on a
corporate intranet.

Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Zane | last post by:
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...
3
by: Lian Liming | last post by:
Hi, The language in my web site may be Simplified Chinese or English. I want to define different styles for each language. For each language, the http header is different. <meta name="language"...
2
by: tagbert | last post by:
I'm trying to localize the setting of colors on a series of webpages by defining color palettes that will be used for various page areas. I've defined some palette classes like .clrLt, .clrMd,...
25
by: Tim & Alethea Larson | last post by:
In order to mark links leaving my site, I recently added this rule to my stylesheet. A:after { content: "\2197" } The character is a northeast-pointing arrow, since that seems to be fairly...
1
by: John Rowe | last post by:
I run the web site for a University department. A few of my authors will carefully write: <h3>Title</h3> <p>Some text here.</p> <p>Second paragraph.</p> Most of us can't be bothered(!): ...
0
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a...
2
by: Chris Sharman | last post by:
See http://services.ccagroup.co.uk/testform.htm Looks as intended in firefox, is valid (bulk of inputs centred in a div occupying the left half of the page). ie ignores the child selector,...
8
by: sajid | last post by:
The CSS 2.1 Specification describes how to sort a list of selectors in order of specificity, but it doesn't provide a method to calculate the specificity of a single selector in isolation. I've...
1
by: jorgedec | last post by:
I have two test vertical menus. If I apply a border-bottom using a selecter of div.vbar a It looks fine. If I apply the border-bottom using a selecter of div.vbar ul li a
6
by: _googlepost | last post by:
I have some CSS that goes something like this: table.TableStyle {font-family: "Helvetica", "Ariel"; background- color:white; border-collapse:collapse;} table.TableStyle COLGROUP { background-...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.