0

I have a text input field (more specifically, in my Angular app, a primeNg maskInput) for which I want to center the text.

I've correctly set the property in my css:

p-inputMask {
    text-align: center;
}

It is valid and picked up by chrome, but somehow it uses the default UA stylesheet instead:

Chrome dev tools

I have the same result in Firefox. If I add text-align: center; inline, it works! I'm puzzled. If it were not valid, I'd understand. If the result were not the same on different browsers, I'd understand. If inline style didn't work, I'd understand. But it seems like it should work!

Edit: Things I've tried:

  • Changing the selector to a class
  • Changing the selector to all input tags
  • Changing the selector to an id
  • Setting the alignment as !important

It is not an inheritance nor specificity problem. The property is picked up by chrome (and simply styling input should have higher priority than the UA stylesheet, unless I'm mistaken). Here is my computed tab:

Computed style tab

Chrome sees my property, but somehow, even if !important (which is the case on this capture), it deems it less important than the vanilla style.

Saucistophe
  • 314
  • 2
  • 10

0 Answers0