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
  • 25,900
  • 45
  • 172
  • 339
  • 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
  • 160,666
  • 24
  • 190
  • 242
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
  • 197,815
  • 30
  • 248
  • 265
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,445
  • 3
  • 26
  • 35
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
  • 249,902
  • 55
  • 405
  • 483
  • 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