5

How can I display the "$" sign through CSS Content:" " I've tried all kinds of different codes. Putting just

div.example {Content:"$1000";}

displays on the site like "00".

Trying to do this before resorting to Javascript.

Sumner Evans
  • 8,951
  • 5
  • 30
  • 47
Sana
  • 73
  • 1
  • 1
  • 5

3 Answers3

16
.dollar:before {
    content: '$';
}
Robin Carlo Catacutan
  • 13,249
  • 11
  • 52
  • 85
  • 1
    Modern usage is `::`. From MDN, *CSS3 introduced the `::before` notation (with two colons) to distinguish **pseudo-classes** from **pseudo-elements**.* -- https://developer.mozilla.org/en-US/docs/Web/CSS/::before – Dem Pilafian Dec 28 '18 at 02:12
1

You can use the following code for displaying the dollar sign in the CSS content property

div.example { content: "\0024"; }
Reg
  • 10,717
  • 6
  • 37
  • 54
shubham jain
  • 113
  • 7
0

There isn't quite enough HTML to go on, but to take a shot:

The CSS property content is to be used with ::before and ::afterand when i put a $ inside my content declaration, everything works...

See JSfiddle here

Brian John
  • 609
  • 3
  • 12