-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSS color is ignored on placeholder text in WebKit and Blink, applied in Gecko #2561
Comments
Note that Gecko's behavior is based on accessibility considerations: it makes it much harder to accidentally create an unreadable placeholder when a page style backgrounds and colors across the board. |
@bzbarsky it seems however to have the opposite effect in the example in OP. Wasn't there a placeholder pseudo-class or pseudo-element? Did that ever get standardized and is that relevant here? |
Well, yes, if you explicitly style the text in your input as "transparent", clearly you're not very interested in anyone reading it in the first place. Also, if you look at the webcompat report, they have other rules that are supposed to override it, but they don't manage to spell "::placeholder" right, so those rules get ignored.
There is a pseudo-element for the placeholder and a pseudo-class for an input with a placeholder. See https://drafts.csswg.org/css-pseudo-4/#placeholder-pseudo and https://drafts.csswg.org/selectors-4/#placeholder respectively.
It's in whatever state CSSWG stuff is in. I think these two are considered fairly stable. In terms of browser support, see http://caniuse.com/#feat=css-placeholder and http://caniuse.com/#feat=css-placeholder-shown respectively. The former is supported by everyone except Edge without prefix as of a few weeks ago, and by Edge with prefix. The latter is supported by everyone except Edge without prefix.
Sort of, in that the page in question tries to style the placeholder using various nonstandard prefix stuff and gets it wrong because the webkit thing is Anyway, all the tools people need to get whatever styling they want are present, if they just use them correctly. The only thing missing is an interoperable set of UA styles. ;) |
Okay, so am I correct that Gecko currently doesn't have default styles for either the pseudo-element or class? And that it's arguably better that way? @tkent-google would you have opinions on this on behalf of Chrome? @hober on behalf of Safari? (I guess a slightly different-but-related topic would be whether HTML needs to more explicitly define when this pseudo-element and class apply. It seems there's some potential for confusion there given the rather opaque descriptions in CSS.) |
Gecko has all sorts of default styles for the the pseudo-element. Most of these are implementation-specific in some sense, because they rely on the details of the internal structure of There is also one ::placeholder-specific UA rule:
which allows users to visually distinguish placeholder text from a value while keeping their colors generally aligned in the common case. |
I filed web-platform-tests/wpt#5625 as a broader issue to discuss whether we should be testing these UA stylesheet things comprehensively; people here may be interested. I don't really know what to do about this particular issue. |
It's nice to define ::placeholder UA stylesheet in the HTML standard for better interoperability. Chrome will follow it. |
so following up on @domenic the CSSWG has decided that UA stylesheet should be part of web platform tests. @tkent-google is it a matter of creating a pull request on the HTML standard or does it need more discussion? Default: As of today latest version of each browser (Canary, Tech Preview, Nightly), except Edge In Chromium (Blink) In WebKit |
@tkent-google is out of office at least until January, but my reading is that he'd support efforts to converge here. I think the first step is deciding which rules exactly were you thinking would be included in the UA stylesheet. Given your links, there is definitely some divergence; what were you hoping to include? |
Sniff sniff more interop issues. https://webcompat.com/issues/12991 |
Another one https://webcompat.com/issues/17190 |
Is there a concrete proposal for a spec change to the UA stylesheet for all browsers to converge on? |
Current browser styles seem to be:
Looks like WebKit diverged from Blink, using a less accessible color ( If a web developer wants to use the same style in all browsers and to normalize on an existing browser's styles, they would need to use one of these three options: /* Gecko style */
::placeholder {
color: inherit;
opacity: 0.54;
}
/* WebKit style */
::placeholder {
color: #9a9a9a;
opacity: 1;
}
/* Blink style */
::placeholder {
color: #757575;
opacity: 1;
} One issue with the opacity approach is that partial opacity can show up as areas with increased contrast in some scripts such as Arabic. I remember similar issues with variable fonts. This is likely a bug in engines, and probably platform-specific. On macOS, both Chrome and Firefox are affected, while Safari doesn't show this issue. |
Given the info in #2561 (comment) about “One issue with the opacity approach is that partial opacity can show up as areas with increased contrast in some scripts such as Arabic”, I guess it also makes sense to make sure @whatwg/i18n are following this. |
Related info from the W3C i18n WG:
Can anyone help add the |
yup, added |
It seems better for the default style for It would be unfortunate to have to pick a specific shade of grey, since browsers may wish to follow a system convention on this by default, but if the UA stylesheet is to be tested, this seems like fair game. (Also it seems like the real interop problem here might be the exposed name of the placeholder pseudo-class/pseudo-element.) |
This might be sorted, since both |
https://html.spec.whatwg.org/multipage/rendering.html#the-input-element-as-a-text-entry-widget
The section on rendering doesn't define the relation of placeholder text to color defined in CSS.
While Blink and WebKit ignores the
color: color_value
, Gecko creates a colored placeholder text.This creates a Web Compatibility issue on deviantart
webcompat/web-bugs#5895
There's an open issue being discussed for Gecko
https://bugzilla.mozilla.org/show_bug.cgi?id=1357674
The text was updated successfully, but these errors were encountered: