Skip to content

[css-selectors-4] [css-pseudo-elements-4] ::placeholder and :placeholder-shown should explicitly apply to textarea elements #6669

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

Closed
astearns opened this issue Sep 23, 2021 · 5 comments

Comments

@astearns
Copy link
Member

The MDN documentation for ::placeholder and :placeholder-shown mention that they apply to textarea and input elements:

https://developer.mozilla.org/en-US/docs/Web/CSS/::placeholder
https://developer.mozilla.org/en-US/docs/Web/CSS/:placeholder-shown

The textarea element is not mentioned in either spec section for these:

https://drafts.csswg.org/css-pseudo/#placeholder-pseudo
https://drafts.csswg.org/selectors/#placeholder

As far as implementations go, ::placeholder appears to work with textareas, but :placeholder-shown has issues.

https://codepen.io/astearns/pen/zYzLaOL

In Mac Firefox, it looks like :placeholder-shown on textareas allows the same properties as ::placeholder (those limited to ::first-line), so you can’t do things like truncate the placeholder text with an ellipsis. In Chrome and Safari, it does not appear to work with textareas at all.

I suggest that we specify what MDN documents (both ::placeholder and :placeholder-shown should work with textarea). This would be specifying reality with regard to ::placeholder, and if that’s acceptable then :placeholder-shown should match.

@astearns astearns added selectors-4 Current Work css-pseudo-4 Current Work labels Sep 23, 2021
@emilio
Copy link
Collaborator

emilio commented Sep 23, 2021

In Mac Firefox, it looks like :placeholder-shown on textareas allows the same properties as ::placeholder (those limited to ::first-line), so you can’t do things like truncate the placeholder text with an ellipsis. In Chrome and Safari, it does not appear to work with textareas at all.

:placeholder-shown is a pseudo-class, not a pseudo-element, so it accepts the same properties as any other selector, nothing specific to ::placeholder. However white-space: nowrap on a textarea's placeholder does nothing, because of this rule. That comes from this commit that changed it to be !important.

It seems that was done because of implementation issues, so I don't think it should matter anymore, I'll try to lift this restriction.

Edit: https://bugzilla.mozilla.org/show_bug.cgi?id=1732267

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Sep 24, 2021
…reviewers,jfkthame

This comes from https://hg.mozilla.org/mozilla-central/rev/0f28fd24bdf3,
and was done because of implementation limitations which don't apply
anymore (https://bugzilla.mozilla.org/show_bug.cgi?id=737786#c33):

 * white-space changes don't reframe anymore, they only reflow.
 * We fixed reframing of native-anonymous content to do the right thing.

This aligns <textarea> and <input>, so I think it should be
uncontroversial.

See w3c/csswg-drafts#6669 for the discussion
that prompted this.

Differential Revision: https://phabricator.services.mozilla.com/D126471
moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Sep 29, 2021
This comes from https://hg.mozilla.org/mozilla-central/rev/0f28fd24bdf3,
and was done because of implementation limitations which don't apply
anymore (https://bugzilla.mozilla.org/show_bug.cgi?id=737786#c33):

 * white-space changes don't reframe anymore, they only reflow.
 * We fixed reframing of native-anonymous content to do the right thing.

This aligns <textarea> and <input>, so I think it should be
uncontroversial.

See w3c/csswg-drafts#6669 for the discussion
that prompted this.

Differential Revision: https://phabricator.services.mozilla.com/D126471

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1732267
gecko-commit: 64bfebfc3f6c63388d8a27b2a0c91020dc859666
gecko-reviewers: layout-reviewers, jfkthame
moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Sep 29, 2021
This comes from https://hg.mozilla.org/mozilla-central/rev/0f28fd24bdf3,
and was done because of implementation limitations which don't apply
anymore (https://bugzilla.mozilla.org/show_bug.cgi?id=737786#c33):

 * white-space changes don't reframe anymore, they only reflow.
 * We fixed reframing of native-anonymous content to do the right thing.

This aligns <textarea> and <input>, so I think it should be
uncontroversial.

See w3c/csswg-drafts#6669 for the discussion
that prompted this.

Differential Revision: https://phabricator.services.mozilla.com/D126471

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1732267
gecko-commit: 64bfebfc3f6c63388d8a27b2a0c91020dc859666
gecko-reviewers: layout-reviewers, jfkthame
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Sep 29, 2021
…reviewers,jfkthame

This comes from https://hg.mozilla.org/mozilla-central/rev/0f28fd24bdf3,
and was done because of implementation limitations which don't apply
anymore (https://bugzilla.mozilla.org/show_bug.cgi?id=737786#c33):

 * white-space changes don't reframe anymore, they only reflow.
 * We fixed reframing of native-anonymous content to do the right thing.

This aligns <textarea> and <input>, so I think it should be
uncontroversial.

See w3c/csswg-drafts#6669 for the discussion
that prompted this.

Differential Revision: https://phabricator.services.mozilla.com/D126471
Gabisampaio pushed a commit to Gabisampaio/wpt that referenced this issue Nov 18, 2021
This comes from https://hg.mozilla.org/mozilla-central/rev/0f28fd24bdf3,
and was done because of implementation limitations which don't apply
anymore (https://bugzilla.mozilla.org/show_bug.cgi?id=737786#c33):

 * white-space changes don't reframe anymore, they only reflow.
 * We fixed reframing of native-anonymous content to do the right thing.

This aligns <textarea> and <input>, so I think it should be
uncontroversial.

See w3c/csswg-drafts#6669 for the discussion
that prompted this.

Differential Revision: https://phabricator.services.mozilla.com/D126471

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1732267
gecko-commit: 64bfebfc3f6c63388d8a27b2a0c91020dc859666
gecko-reviewers: layout-reviewers, jfkthame
@fantasai
Copy link
Collaborator

fantasai commented Nov 8, 2022

@astearns I don't think the CSS specs need any edits here, so let me know if we can close out this issue!

@astearns
Copy link
Member Author

astearns commented Nov 9, 2022

@fantasai I do not think it is clear in the CSS specs that these both have effects on textarea elements as well as input elements. I’d like both sections to at least mention the textarea element.

@fantasai
Copy link
Collaborator

@astearns I've added TEXTAREA to the example in Selectors 4 and copied it over into the Pseudo-Elements spec as well. Is this enough to close the issue?

@astearns
Copy link
Member Author

Yes. Thanks!

jakearchibald pushed a commit to jakearchibald/csswg-drafts that referenced this issue Jan 16, 2023
jakearchibald pushed a commit to jakearchibald/csswg-drafts that referenced this issue Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants