Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to format price with currency symbol in HTML5?

Tags:

html

css

I have to show price $1.99 like $199, but I want to make sure that Google indexes $1.99 and not $199.

Different variation for i18n/localization.

$1.99 = $199
€1.55 = €155
CAN$2.99 = CAN$299

Thanks.

like image 514
dean Avatar asked Feb 04 '26 20:02

dean


2 Answers

You can wrap the decimal point (the period in this case) in a span and set it to display: none.

like image 196
Daniel A. White Avatar answered Feb 06 '26 11:02

Daniel A. White


try this fiddle: http://jsfiddle.net/d7vMb/2/

html

CAN$2.99 = CAN$2.<span>99</span>

css

span {
    position       : relative;
    left           : -.3em;
    vertical-align : super;   
    padding-bottom : .38em;
    background     : #fff; /* this will cover the dot */
    font-size      : 0.76em;
}

I tried to change the font-size from 1 to 20 em and it seems correctly working (no unwanted overlaps). In this way you can also avoid display: none.

like image 31
Fabrizio Calderan Avatar answered Feb 06 '26 12:02

Fabrizio Calderan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!