Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Superscript price decimal numbers when using Standard Numeric Format Strings

I'm using Standard Numeric Format Strings (see here) to format pricing on my page:

Dim price As Integer = 378
Dim s As String = (CDec(price) / 100).ToString("F")

results in string "3,78" which I print in HTML.

However, I want the decimal part "78" to be superscripted using HTML/CSS. How can I do so?

like image 939
Adam Avatar asked Dec 17 '25 17:12

Adam


1 Answers

Unless the text is automatically HTML encoded (and you have access to the source of all this) you can use the <sup> tag.

To superscript only the 78 part just split the string by , (or . if that is the case) into an array and join it together again with the tag included.

For example:

Dim Parts() As String = s.Split(If(s.Contains("."), ".", ","))
Dim s2 As String = Parts(0) & ",<sup>" & Parts(1) & "</sup>"
like image 85
Visual Vincent Avatar answered Dec 19 '25 08:12

Visual Vincent



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!