Input elements can't have ::before or ::after content due to being Replaced Elements #19714
Labels
Content:Learn:Forms
Learning area Forms docs
help wanted
If you know something about this topic, we would love your help!
MDN URL
https://developer.mozilla.org/en-US/docs/Learn/Forms/UI_pseudo-classes#using_generated_content_with_pseudo-classes
What specific section or headline is this issue about?
Using generated content with pseudo-classes
What information was incorrect, unhelpful, or incomplete?
The example given is wrong or at least misleading. An element is considered a Replaced Element and does not allow ::before or ::after pseudo elements (even though, strangely, the example given in the page of adding to a radio button does work).
The page then goes on to correctly say "Since form inputs don't directly support having generated content put on them (this is because generated content is placed relative to an element's formatting box, but form inputs work more like replaced elements and therefore don't have one)" – This seems incongruent with the prior example (which clearly uses a form input… and works)!
What did you expect to see?
It might be useful to note that "While our radio button example does allow styling, this is a bit of a strange case and does not apply to most form inputs"
Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
No response
The text was updated successfully, but these errors were encountered: