0

Im trying to use hex value for bullet in CSS as mentioned here Can you use HTML entities in the CSS “content” property?

Note that I don't want to use <li> element just to show bullet

<table>
    <tr>
        <td>
            <span class="mybullet"/> <a href="#">Link1</a>
        </td>        
    </tr>
</table>

.mybullet
{
    content:"\2022 ";
    color:#f00;
}

however its not working. Here is the JsFiddle http://jsfiddle.net/kq2fzb2v/

Community
  • 1
  • 1
LP13
  • 30,567
  • 53
  • 217
  • 400
  • Why do you use a table? And note self-closing `span` elements won't work in HTML, only in XHTML. – Oriol May 29 '15 at 16:46

4 Answers4

2

Use either :before or :after:

.mybullet:before
{
    content: "\2022";
    color: #f00;
    display: inline-block;
}

.mybullet:before {
  content: "\2022";
  color: #f00;
}
<table>
  <tr>
    <td>
      <span class="mybullet" /> <a href="#">Link1</a>
    </td>
  </tr>
</table>
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
0

You need to add the ::before pseudo-element to your code:

.mybullet::before {
    content:"\2022 ";
    color:#f00;
}
<table>
    <tr>
        <td><span class="mybullet" /> <a href="#">Link1</a>

        </td>
    </tr>
</table>
j08691
  • 204,283
  • 31
  • 260
  • 272
0

use :before or :after

<span/> to <span></span>

.mybullet:before
{
    content:"\2022 ";
    color:#f00;
    display: inline-block;
}
<table>
    <tr>
        <td>
            <span class="mybullet"> <a href="#">Link1</a></span>
        </td>        
    </tr>
</table>
Dmitriy
  • 4,475
  • 3
  • 29
  • 37
0

The content property only applies to the ::before and ::after pseudo-elements:

.mybullet:before {
  content: "\2022  ";
  color: #f00;
}
<span class="mybullet"><a href="#">Link1</a></span>

Alternatively, even if you don't want to use a li element, you may style it as a list item:

.mybullet {
  display: list-item;
  list-style: inside disc;
}
<span class="mybullet"><a href="#">Link1</a></span>
Oriol
  • 274,082
  • 63
  • 437
  • 513
  • Thanks All. All the answers above seems to be working..yes, I will change the self closing span..thanks for pointing out – LP13 May 29 '15 at 18:31