<ul> list item bullet colors

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dp

    <ul> list item bullet colors

    Is there anyway to have the bullet color of a <li> be a different color than
    the text without using an image?
    dp


  • la_haine

    #2
    Re: &lt;ul&gt; list item bullet colors

    "dp" <noreplyhere@ho tmail.com> wrote in
    news:Pi9Nc.48$Z 56.17@newssvr33 .news.prodigy.c om:
    [color=blue]
    > Is there anyway to have the bullet color of a <li> be a different color
    > than the text without using an image?[/color]

    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

    Comment

    • Claire Tucker

      #3
      Re: &lt;ul&gt; list item bullet colors

      On Mon, 26 Jul 2004 15:20:15 GMT, "dp" <noreplyhere@ho tmail.com>
      wrote:
      [color=blue]
      >Is there anyway to have the bullet color of a <li> be a different color than
      >the text without using an image?
      >dp
      >[/color]

      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

      Comment

      • dp

        #4
        Re: &lt;ul&gt; list item bullet colors


        "Claire Tucker" <fake@invalid.i nvalid> wrote in message
        news:mjddg05tdt nqmatloq4m6hn4h c8oa161d0@4ax.c om...[color=blue]
        > On Mon, 26 Jul 2004 15:20:15 GMT, "dp" <noreplyhere@ho tmail.com>
        > wrote:
        >[color=green]
        > >Is there anyway to have the bullet color of a <li> be a different color[/color][/color]
        than[color=blue][color=green]
        > >the text without using an image?
        > >dp
        > >[/color]
        >
        > 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[/color]

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


        Comment

        • Claire Tucker

          #5
          Re: &lt;ul&gt; list item bullet colors

          On Thu, 29 Jul 2004 01:24:31 GMT, "dp" <noreplyhere@ho tmail.com>
          wrote:[color=blue]
          >"Claire Tucker" <fake@invalid.i nvalid> wrote in message
          >news:mjddg05td tnqmatloq4m6hn4 hc8oa161d0@4ax. com...[color=green]
          >>
          >> 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;
          >> }
          >>[/color]
          >Tried with latest versions of IE, Mozilla, Firefox and Opera, but no joy.[/color]

          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

          Comment

          • Chris Morris

            #6
            Re: &lt;ul&gt; list item bullet colors

            Claire Tucker <fake@invalid.i nvalid> writes:[color=blue]
            > 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;
            > }[/color]

            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;
            }
            [color=blue]
            > 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.[/color]

            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

            Comment

            • Brian

              #7
              Re: &lt;ul&gt; list item bullet colors

              Claire Tucker wrote:
              [color=blue]
              > 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; }[/color]

              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)

              Comment

              • Claire Tucker

                #8
                Re: &lt;ul&gt; list item bullet colors

                On Thu, 29 Jul 2004 10:42:47 -0400, Brian
                <usenet3@juliet remblay.com.inv alid> wrote:
                [color=blue]
                >Claire Tucker wrote:
                >[color=green]
                >> 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; }[/color]
                >
                >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 {}[/color]

                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

                Comment

                • gretelob
                  New Member
                  • Feb 2006
                  • 1

                  #9
                  Originally posted by dp
                  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?

                  Comment

                  Working...