473,396 Members | 1,940 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,396 software developers and data experts.

To match a particular <li> element

Hi at all,
please consider this :
<ul>
<li><a>No link</a></li>
<li><a href="#">This is a link</a></li>
<li><a>No link</a></li>
<li><a href="#">This is a link</a></li>
....................
</ul>
How can I do to match the <li> element that have as son the <a
href="www.----------">??? or viceversa the <li> elements that have only the
<a> into?

Thank you very much
Steel


Jul 21 '05 #1
5 1823
"Steel" <St*********@hotmail.com> wrote:
<li><a>No link</a></li>
<li><a href="#">This is a link</a></li> How can I do to match the <li> element that have as son the <a
href="www.----------">??? or viceversa the <li> elements that have only the
<a> into?


Remove the pointless <a>No link</a> anchor element.

--
Spartanicus
Jul 21 '05 #2
On Fri, 18 Mar 2005 10:09:52 +0100, Steel <St*********@hotmail.com> wrote:
Hi at all,
please consider this :
<ul>
<li><a>No link</a></li>
<li><a href="#">This is a link</a></li>
<li><a>No link</a></li>
<li><a href="#">This is a link</a></li>
...................
</ul>
How can I do to match the <li> element that have as son the <a
href="www.----------">??? or viceversa the <li> elements that have only
the
<a> into?


You can't select an element based on what elements it contains. You can
however select the contents in the list example above:

li a[href] {} /* For CSS2 browsers like Mozilla, Opera and Safari */

or

li a:link, li a:visited {} /* For CSS 1 browsers like MSIE 6 and Netscape
4, works also in CSS2 browsers */
--
Rijk van Geijtenbeek

The Web is a procrastination apparatus:
It can absorb as much time as is required to ensure that you
won't get any real work done. - J.Nielsen

Jul 21 '05 #3
"Steel" wrote in comp.infosystems.www.authoring.stylesheets:
<li><a href="#">This is a link</a></li>


This is broken, unless you actually want the link to take the user
to the top of the current page.

--

Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
Jul 21 '05 #4
I simply need to match the father (<li>) af a <a> that can have the href or
not
In my menu only the last choice-level have the href but I do not know how
many level are nested.
Steel
"Stan Brown" <th************@fastmail.fm>
wrote:
This is broken, unless you actually want the link to take the user to the top of the current page.
--

Jul 21 '05 #5
Steel wrote:
I simply need to match the father (<li>) af a <a> that can have the href or
not
In my menu only the last choice-level have the href but I do not know how
many level are nested.
Steel

CSS cannot differ between elements of the same type unless they have
different class, id or is unique in that it is the only node within its
hiearchy and the node is known before the page is rendered.
Examples:

<ul>
<li><a class="link"> 1
<li><a class="link"> 1
<li><a class="link"> 1
<li><a class="link" id="somelink"> 1,2
<li><a id="lastlink"> 3
<ul>
<li><a> 4
</ul>
</ul>

1: Styles defined as a.link {} will apply to all with the class="link"
2: Syles defined as a#somelink {} will only apply to an <a> with
id="somelink". The id style wins over class style in a conflict.
3: The style #lastlink will only apply to the <a> with id="lastlink"
4: The style ul li ul li a {} will only apply to <a> inside a <li>
inside a <ul> inside a <li> inside a <ul>

If your page is generated by a script, you can assign a class or id to
the different elements you want to apply special effects to. Otherwise
you must probably use a client side javascript that browses through the
DOM and do the changes there. I am not proficient enough with javascript
to tell you how.
Jul 21 '05 #6

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

Similar topics

8
by: Michael | last post by:
This is a two-part question to which I haven't been able to find an answer anywhere else. 1. Is it possible to format the bullet/number character of the <li>? In my styles sheet, I have the <li>...
3
by: NWhite | last post by:
Hi all, I'm trying to indent <li> items using: li { margin: 0 0 0 50px;} So I expect something like the following to indent 50 pixels from the left margin:
4
by: Kerberos | last post by:
I haven't been able to define a fixed width (well, I chose a 20% width) for the li element used in the navigation menu: http://www.auriance.com/docs/auriance/ Style sheet here:...
4
by: Matt | last post by:
Hi, Got an unordered list with 100% width, with 5 list items of 20% width styled to fill the width of the container element. Renders fine in Mozilla, but when you change the size of the window...
1
by: A | last post by:
Hi all, i must distinguish <LI> elements with an anchor element and :Link and LI elements with anchor but without :link. how can i get these elements? Bye Paolo
4
by: Mark | last post by:
Hopefully I 'm missing something silly, but I can't find an easy way to loop all list items in a simple <ol>. I was hoping a for loop as shown below would be enough, however clicking "alert all" in...
4
by: abs | last post by:
Anybody has an idea how to get the <ul> element which is not nested in <li> element ? In other words I have several lists like this: <ul id="1"> <li>Aaaaaaaa</li> <li>Bbbbbbbb</li>...
2
by: Andrew Donaldson | last post by:
I'd welcome some help in understanding what's going on with graphical browsers in the navigation list at: http://www.bounceandtickle.org.uk/index.html (This site is not about what it might...
7
by: patrick j | last post by:
Hi I'm wondering about lists with nested lists as one does on a Saturday afternoon. Anyway below is an example of a list with a nested list which the iCab browser's very useful HTML...
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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.