How to align text elements using the $w.html?

I was trying to align the text to the center on mobile using text.html, everything is working fine except the text alignment, here’s the code that I used on mobile and a photo demonstrating the purpose.

$item('#price').html = "<span style='text-align: center; font-family: janna, arial; font-size: 20px; font-weight: bold; color: #E84A43' >" + comboPrice + "</span>";

Here is the photo, am I doing it wrong? If so, what’s the right way to do it?

Am I doing it wrong? If so, what’s the right way to do it?

Appreciate the advice.
Ahmad

Hi, I’ve found a way around, but I still want to know why it didn’t work.

The solution for me was to add the tag.

$item('#price').html = "<span style='font-family: janna, arial; font-size: 20px; font-weight: bold; color: #E84A43' >" + "<center>" + comboPrice + "</center>" + "</span>";

Here is the result:

Adding div to define text alignment worked for me.

<div style="text-align: right;"><span style = "color:${chgColor};font-size: ${txtSize}px;"> ${chgtext} </span></div>

text-align property may not work for elements, but only for block-level elements like div or p . You can try to wrap your span element inside a div element and apply the text-align property to the div element instead.