473,769 Members | 5,131 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

<ul> list item bullet colors

dp
Is there anyway to have the bullet color of a <li> be a different color than
the text without using an image?
dp
Jul 20 '05 #1
8 53691
"dp" <no*********@ho tmail.com> wrote in
news:Pi******** *****@newssvr33 .news.prodigy.c om:
Is there anyway to have the bullet color of a <li> be a different color
than the text without using an image?


quick and dirty way with extra markup:

<li><span>list1 </span></li>

and in your stylesheet:

li {
color: #ff0000;
}

span {
color: #000000;
}

There may be a better way of doing this without the redundant markup - if
your list items are links then you could of course replace the span element
with an a element.

--
We generally describe the most repulsive examples of humanity's cruelty as
brutal or bestial, implying by these adjectives that such behaviour is
characteristic of less highly developed animals such as ourselves. In truth,
however, the extremes of 'brutal' behaviour are confined to humanity; and
there is no parallel in nature to our savage treatment of each other.
- Storr, 1968
Jul 20 '05 #2
On Mon, 26 Jul 2004 15:20:15 GMT, "dp" <no*********@ho tmail.com>
wrote:
Is there anyway to have the bullet color of a <li> be a different color than
the text without using an image?
dp


In a CSS2-supporting browser, the bullet may be in the :before box of
the list item, so changing the color of this may work:

li:before {
color: pink;
}

However, in browsers which do not implement lists in this manner, this
will have no effect. At least when it doesn't work the viewer will
just see a normal-colored bullet. Most viewers won't even notice the
difference! :)

Best regards,
-Claire
Jul 20 '05 #3
dp

"Claire Tucker" <fa**@invalid.i nvalid> wrote in message
news:mj******** *************** *********@4ax.c om...
On Mon, 26 Jul 2004 15:20:15 GMT, "dp" <no*********@ho tmail.com>
wrote:
Is there anyway to have the bullet color of a <li> be a different color thanthe text without using an image?
dp


In a CSS2-supporting browser, the bullet may be in the :before box of
the list item, so changing the color of this may work:

li:before {
color: pink;
}

However, in browsers which do not implement lists in this manner, this
will have no effect. At least when it doesn't work the viewer will
just see a normal-colored bullet. Most viewers won't even notice the
difference! :)

Best regards,
-Claire


Thanks Claire,
Tried with latest versions of IE, Mozilla, Firefox and Opera, but no joy.
dp
Jul 20 '05 #4
On Thu, 29 Jul 2004 01:24:31 GMT, "dp" <no*********@ho tmail.com>
wrote:
"Claire Tucker" <fa**@invalid.i nvalid> wrote in message
news:mj******* *************** **********@4ax. com...

In a CSS2-supporting browser, the bullet may be in the :before box of
the list item, so changing the color of this may work:

li:before {
color: pink;
}

Tried with latest versions of IE, Mozilla, Firefox and Opera, but no joy.


It looks like Mozilla Seamonkey (and Firefox) specify the default
rendering for lists using CSS1 list properties rather than CSS2
markers as I first assumed. (see res/html.css in the FireFox/Seamonkey
directory to see how Mozilla implements the rendering of each element.
Some of them are quite interesting...)

You could, theoretically, disable the CSS1 list properties and use
CSS2 markers instead, but in my testing I was left unsure of whether
Opera and Firefox were actually respecting the marker properties or if
they were just ignoring it and making regular generated content:

ul {
list-style: none;
}
ul li:before {
display: marker;
content: "\2022 ";
color: #0000ff;
}

Since IE doesn't support generated content or :before, it'll render
this without any bullets at all. You may like to "hide" the first rule
from IE by using a child selector, which IE doesn't support and will
thus skip:

body > ul {
list-style: none;
}

This will make the lists appear with non-special bullets in IE, but
your colored bullets will now, of course, only work right if the list
is a direct child of the BODY element.

Also, exploiting a browser's lack of support of something to hide
things from it is a risky business for a number of reasons, most
notably because a future version of IE might support child selectors
but not generated content, or vice-versa. In the latter case, you
might end up with two sets of bullets! That's not to mention that
there might already be a browser out there in the wild which supports
generated content but not child selectors. Beware.

Best of luck,
-Claire
Jul 20 '05 #5
Claire Tucker <fa**@invalid.i nvalid> writes:
Since IE doesn't support generated content or :before, it'll render
this without any bullets at all. You may like to "hide" the first rule
from IE by using a child selector, which IE doesn't support and will
thus skip:

body > ul {
list-style: none;
}
Note that this only hides from Windows IE.

To hide from both Windows and Mac IE (which I think is better in this
case), use
ul,[IEhide] {
list-style: none;
}
This will make the lists appear with non-special bullets in IE, but
your colored bullets will now, of course, only work right if the list
is a direct child of the BODY element.


A good way around this one is "html>body ul {...}" (all ul that are
descendants of a body that is a direct child of a html - i.e. all of
them)

--
Chris
Jul 20 '05 #6
Claire Tucker wrote:
You may like to "hide" the first rule from IE by using a child
selector, which IE doesn't support and will thus skip:

body > ul { list-style: none; }


ITYM IE/Win -- IE 5/Mac does child selectors just fine -- but even that
is wrong. IE/Win will not ignore this rule; it will treat it like a
descendent selector:

body ul {}

To hide it, there must be no spaces in the rule, like so:

body>ul {}

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #7
On Thu, 29 Jul 2004 10:42:47 -0400, Brian
<us*****@juliet remblay.com.inv alid> wrote:
Claire Tucker wrote:
You may like to "hide" the first rule from IE by using a child
selector, which IE doesn't support and will thus skip:

body > ul { list-style: none; }


ITYM IE/Win -- IE 5/Mac does child selectors just fine -- but even that
is wrong. IE/Win will not ignore this rule; it will treat it like a
descendent selector:

body ul {}

To hide it, there must be no spaces in the rule, like so:

body>ul {}


I was quite surprised to read this, since I've been doing the "trick"
as I described it for a few years now despite my better judgement. I
knocked up a quick test, and found that the way I wrote it confounds
IE as well. What IE is doing with it I have no idea; It did seem to be
the case that IE was considering it invalid and doing
forward-compatible skipping in this case, though, as adding further
valid selectors didn't convince IE to apply the suggestion:

div > p, h1 {
font-size: 2em;
color: blue;
}

The h1 element in my test document remained unaffected, as I'd hoped.

Does IE5 on Mac support :before and generated content, I wonder?

All the best,
-Claire
Jul 20 '05 #8
gretelob
1 New Member
Is there anyway to have the bullet color of a <li> be a different color than
the text without using an image? dp
Is there an answer to this?
Feb 25 '06 #9

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

Similar topics

8
4662
by: bearclaws | last post by:
I am looping through a list of categories and want to display the list horizontally (instead of vertically). I want to create a single row with 4 list items in each cell of the row. I thought this would work but I get this error: "End tag 'xsl:if' does not match the start tag 'ul'." Any thoughts?
8
6888
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> tag formatted, for example, bold. However, when it's applied, the number of the <li> is not bold, but the text is. Do I have to apply the bold to the <ol> instead? 2. When I use <li>example text</li>, and when I insert a <br> after the </li>,...
1
3755
by: Randall Sell | last post by:
OK, I am utterly stumped. The code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <style type="text/css"> ul { background-color: red; }
5
9245
by: toylet | last post by:
Attached is some css codes for a website. It has 3 parts: top-bar, side-bar (on the left) and main-body. The top-bar has a mouseover menu called top-menu implemented via ul:hover. When the mouse pointer hovers over the top-menu, the bottom margin of the top-bar expands downwards. How could I make the hover menu to stack on top of the main-body, not expanding the bottom margin of the top-bar? I believe it has something to do with...
3
2283
by: Jordan Peterson | last post by:
When using {list-style: none} to hide the bullets in a <ul>, the bullets disappear but they are still accounted-for when positioning text. Specifically, I have: <div style='text-align: center'> <ul style='list-style: none> <li>...</li> <li>...</li> <li>...</li>
2
12058
by: Jerry | last post by:
I've got a website that uses an external style sheet to manage several of the design elements. One of the webpages includes an unordered list. I would like for the list to not be indented at all, with the bullets directly below the left margin of a standard paragraph of text. All of the content is included in a table cell. I was able to accomplish that when viewed in IE, using the following CSS snippet, but both NS and FireFox displays the...
6
2300
by: ashkaan57 | last post by:
Hi, How can I set up the styling for different levels of <ULto use different images for bullets, be indenetd differently, ... Like: .. list 1 - item 1 - item 2 .. list 2
19
11636
by: ashkaan57 | last post by:
Hi, I have a page in a right-to-left language and I am trying to make some bulleted lists using <ul>, but it puts the bullets to the left. Is there any way I can set the bullets to be on the right: ..lists { margin:2em 0 0 2em; } ..lists ul {
6
4472
by: capricious | last post by:
Is it possible, so that when you do multiple <UL>'s to control how deep the UL's are marked? For example, it would defaultly look like this with multiple ULs and LIs: -- Code : Main Menu<ul>Fruits<ul><li>Apples</li><li>Oranges</li></ul></ul> .. -- Returns :
0
9583
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10210
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9990
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8869
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6668
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5297
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5445
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3955
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.