6

Using the css content property, I am trying to make put an HTML entity after an element.

Here is my HTML:

<table id="tic" cellpadding="0" cellspacing="0" border="5" bordercolor="black" bordercolorlight="gray" bgcolor="white">
    <tr>
        <td width="55" height="55" class="x"></td>
        <td width="55" height="55" class="o"></td>
        <td width="55" height="55" class="x"></td>
    </tr>
    <tr>
        <td width="55" height="55" class="o"></td>
        <td width="55" height="55" class="x"></td>
        <td width="55" height="55" class="o"></td>
    </tr>
    <tr>
        <td width="55" height="55" class="x"></td>
        <td width="55" height="55" class="o"></td>
        <td width="55" height="55" class="x"></td>
    </tr>
</table>

And my CSS:

table{
    text-align:center;
    font-size:2em;
    font-weight:bold;
}
td.o:after{
    content:"&#9675;";
    font-weight:bold;
}
td.x:after{
    content:"&#x2716;"
}

Unfortunately, instead of getting the ○ character and the ✖ character, I get the entity names.

FIDDLE

How can I fix this? Thanks!

2

4 Answers 4

4

CSS isn't HTML. You can't use HTML entities in it.

Use the literal character () or a CSS unicode escape instead.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, this worked for me. Unfortunately I can't accept it for eight more minutes… :(
8 minutes have past...
3

You have to use the escaped unicode :

Like

td.o:after {
    content:"\00a2"; 
}
td.x:after {
    content:"\00a4"; 
}

More info on : http://www.evotech.net/blog/2007/04/named-html-entities-in-numeric-order/

Comments

0

Try

td.o:after{
    content:"\9675";
    font-weight:bold;
}
td.x:after{
    content:"\2716"
}

For the first one, it gives another symbol, so please check if you used the right code for it...

http://jsfiddle.net/7XXbK/

Comments

0

Here's a working fiddle for you:

http://jsfiddle.net/Dp78c/4/

table{
    text-align:center;
    font-size:2em;
    font-weight:bold;
}
td.o:after{
    content:"\25CB";
    font-weight:bold;
} 
td.x:after{
    content:"\2716";
}

You need to use the unicode escaped character instead. You can use this tool to translate for you as well if you need to:

http://www.evotech.net/articles/testjsentities.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.