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

<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 53667
"dp" <no*********@hotmail.com> wrote in
news:Pi*************@newssvr33.news.prodigy.com:
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*********@hotmail.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.invalid> wrote in message
news:mj********************************@4ax.com...
On Mon, 26 Jul 2004 15:20:15 GMT, "dp" <no*********@hotmail.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*********@hotmail.com>
wrote:
"Claire Tucker" <fa**@invalid.invalid> 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.invalid> 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*****@julietremblay.com.invalid> 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
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
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...
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>...
1
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 {...
5
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...
3
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:...
2
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,...
6
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
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...
6
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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...

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.