HighDots Forums  

Possible to Change List Bullet Color?

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Possible to Change List Bullet Color? in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
spm
 
Posts: n/a

Default Possible to Change List Bullet Color? - 09-23-2007 , 05:46 PM






I've got an unordered list with a list-style-type of 'square.' The
color of this (and the text in the list) is black.

Is it possible, via the CSS, to specify the color of this square (i.e.
make the bullet red) without changing the color of the text in the list
also?

For example, setting 'color: red' makes the square and text red, but I
want the square to be red and the text to remain black.

I was hoping for a quick way of achieving this and would rather not
specify a small gif image as the bullet-image.

Thanks for any help.


Reply With Quote
  #2  
Old   
Joshua Cranmer
 
Posts: n/a

Default Re: Possible to Change List Bullet Color? - 09-23-2007 , 05:57 PM






spm wrote:
Quote:
I've got an unordered list with a list-style-type of 'square.' The color
of this (and the text in the list) is black.

Is it possible, via the CSS, to specify the color of this square (i.e.
make the bullet red) without changing the color of the text in the list
also?
Under CSS 2.1, no.[*]

The current WD of the CSS 3 Lists module does specify the ::marker
pseudo-element which would do exactly what you want; FF has been tested
to not support ::marker and I doubt that either Safari or Opera has it.
IE, of course, does not support it.
[*] Not directly, at least. Wrapping a <span class="foo"> within each
<li> element allows you to do this, but it is relatively hack-ish.
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth


Reply With Quote
  #3  
Old   
Thom Little
 
Posts: n/a

Default Re: Possible to Change List Bullet Color? - 09-24-2007 , 06:55 AM



You could make the bullet an image and then use something like the following
to invoke it ...

ul
{
list-style-image : url( "http://www.xxxxxxxx.com/bullet.gif" );
}

.... Thom
__________________________________________________ _
Thom Little - www.tlanet.net - Thom Little Associates, Ltd.

Reply With Quote
  #4  
Old   
spm
 
Posts: n/a

Default Re: Possible to Change List Bullet Color? - 09-24-2007 , 04:13 PM



On 2007-09-23 23:57:26 +0100, Joshua Cranmer <Pidgeot18 (AT) verizon (DOT) net> said:

Quote:
spm wrote:
I've got an unordered list with a list-style-type of 'square.' The
color of this (and the text in the list) is black.

Is it possible, via the CSS, to specify the color of this square (i.e.
make the bullet red) without changing the color of the text in the list
also?

Under CSS 2.1, no.[*]

The current WD of the CSS 3 Lists module does specify the ::marker
pseudo-element which would do exactly what you want; FF has been tested
to not support ::marker and I doubt that either Safari or Opera has it.
IE, of course, does not support it.
[*] Not directly, at least. Wrapping a <span class="foo"> within each
li> element allows you to do this, but it is relatively hack-ish.
Thanks for the explanation Joshua. I'll look forward to CSS 3 in that
case, though I guess it'll be several years yet before the
specification is even agreed, never mind supported by the major
browsers of the day.

Thanks.



Reply With Quote
  #5  
Old   
spm
 
Posts: n/a

Default Re: Possible to Change List Bullet Color? - 09-24-2007 , 04:14 PM



On 2007-09-24 12:55:17 +0100, "Thom Little" <thom (AT) tlanet (DOT) net> said:

Quote:
You could make the bullet an image and then use something like the following
to invoke it ...

ul
{
list-style-image : url( "http://www.xxxxxxxx.com/bullet.gif" );
}

... Thom
__________________________________________________ _
Thom Little - www.tlanet.net - Thom Little Associates, Ltd.

Yes, I was hoping to do it with CSS, but other than use the hack that
Joshua posted, I guess the above is the most efficient and 'hack free'
way I can do this.

Thanks.



Reply With Quote
  #6  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Possible to Change List Bullet Color? - 09-24-2007 , 11:31 PM



Scripsit Johannes Koch:

Quote:
Note, that browsers won't resize the image specified with
list-style-image, when the user changes the font size.
Unfortunately, we have the same problem with the default list bullets, and
generally with list markers. So I don't think this is a strong argument
against using images a list bullets - though, theoretically, we can argue
that browsers _should_ scale the default bullets (and markers settable with
list-style-type) according to font size.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
  #7  
Old   
Johannes Koch
 
Posts: n/a

Default Re: Possible to Change List Bullet Color? - 09-25-2007 , 02:36 AM



Jukka K. Korpela schrieb:
Quote:
Scripsit Johannes Koch:

Note, that browsers won't resize the image specified with
list-style-image, when the user changes the font size.

Unfortunately, we have the same problem with the default list bullets,
Well, at least my Firefox 1.5.0.12, IE 7.0.5730.11, Opera 9.22 (all Win)
resize the default list bullets when resizing the text.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)


Reply With Quote
  #8  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Possible to Change List Bullet Color? - 09-25-2007 , 07:42 AM



Scripsit Johannes Koch:

Quote:
Jukka K. Korpela schrieb:
Scripsit Johannes Koch:

Note, that browsers won't resize the image specified with
list-style-image, when the user changes the font size.

Unfortunately, we have the same problem with the default list
bullets,

Well, at least my Firefox 1.5.0.12, IE 7.0.5730.11, Opera 9.22 (all
Win) resize the default list bullets when resizing the text.
Right, sorry, I was thinking about other matters... namely CSS. When I use
the browser's font size control, then the bullet size indeed changes, but if
I set, say,

<ul style="font-size:300%">

(just to make a point [no pun intended]), the default bullets keep their
size, resulting in a grotesque mismatch between their size and text size.

The only way to make bullets get the same size as text is to make them part
of the textual content somehow. Using :before pseudo-elements and generated
content, this would be possible in pure CSS, but IE still doesn't support
them.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
  #9  
Old   
dorayme
 
Posts: n/a

Default Re: Possible to Change List Bullet Color? - 09-25-2007 , 04:23 PM



In article <Gl7Ki.228573$ad4.74032 (AT) reader1 (DOT) news.saunalahti.fi>,
"Jukka K. Korpela" <jkorpela (AT) cs (DOT) tut.fi> wrote:

Quote:
The only way to make bullets get the same size as text is to make them part
of the textual content somehow. Using :before pseudo-elements and generated
content, this would be possible in pure CSS, but IE still doesn't support
them.
Or perhaps using an image inside the list item and dimensioning
it in ems.

--
dorayme


Reply With Quote
  #10  
Old   
Joshua Cranmer
 
Posts: n/a

Default Re: Possible to Change List Bullet Color? - 09-25-2007 , 04:38 PM



spm wrote:
Quote:
Thanks for the explanation Joshua. I'll look forward to CSS 3 in that
case, though I guess it'll be several years yet before the specification
is even agreed, never mind supported by the major browsers of the day.

Thanks.

From what I have gathered from observing some of the specs, a sizable
portion of CSS 3 is sufficiently stable enough to be worth reading and
some of it even enjoys (sometimes) widespread support. The best example
is Selectors, where everything but the pseudo-elements, and some of the
pseudo-classes are supported in several browsers (IE and Safari don't
appear to take namespacing into account--that is probably a special
issue not wholly relevant here).

I would be willing to bet that much of the actual RECs that come out of
CSS 3 will have at least as much as the current WD states, the only
exception being some of the thornier i18n issues. Support, though, is
still mostly hard-to-find and in experimental regimes.

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.