In CSS, you can stylize placeholder text inside input using a combination of pseudo-classes and vendor-specific pseudo-elements (to get better cross-browser coverage).
All of them have the same basic properties (that is: stylization of text and color declarations).
However, despite the fact that I inevitably want to apply the same styles regardless of the browser provider, it seems impossible to combine them together in a comma separated selector (as with any other CSS fragment where you want two selectors to use the same styles).
As an example, I tend to focus on placeholder style using the following four selectors:
input:-moz-placeholderinput::-moz-placeholderinput:-ms-input-placeholderinput::-webkit-input-placeholder
(although :-moz-placeholder deprecated in favor of ::-moz-placeholder , this only happened with the release of FireFox 19, so currently both are necessary for better browser support).
What is frustrating is that declaring and providing each (the same) style leads to a lot of repetition in CSS.
So, to make sure the placeholder text is right-aligned and italicized, I get:
input:-moz-placeholder{ font-style: italic; text-align: right; } input::-moz-placeholder{ font-style: italic; text-align: right; } input:-ms-input-placeholder{ font-style: italic; text-align: right; } input::-webkit-input-placeholder{ font-style: italic; text-align: right; }
What I really want to do is combine them into one single rule, separated by commas:
input:-moz-placeholder, input::-moz-placeholder, input:-ms-input-placeholder, input::-webkit-input-placeholder{ font-style: italic; text-align: right; }
However, even though this has happened several times, this does not seem to work. My concern is that there is some fundamental part of CSS that I don't understand.
Can anyone shed some light on why this is happening?
css css-selectors css3 pseudo-class pseudo-element
johnkavanagh Jun 07 '13 at 10:57 2013-06-07 10:57
source share