This isn't exactly a bug. There is simply no spec yet that browser vendors can follow. It appears that instead :placeholder-shown
is on track to be standardized, although browsers do not support it right now.
The non-standard ::-moz-placeholder
is restricted in what style rules it may accept. text-align
is not one of the accepted rules (The rule doesn't have the CSS_PROPERTY_APPLIES_TO_PLACEHOLDER
bit set).
So you cannot use text-align
with ::-moz-placeholder
at the time of writing.
However, you can text-align
the whole <input>
.
If you only want the placeholder text centered, but not entered text, then you may add some Javascript to set .style.textAlign
according to the <input>.value
when it changes. That's a nasty work-around, but should work. E.g. see this fiddle.
<input>.addEventListener("input", function(e) {
this.style.textAlign = this.value === "" ? "center" : "left";
});