You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Give authors the ability to style form validation messages #7172
In this tweet, the author asks for this functionality.
Css really needs to be able to style this browsers popups with an error messages in inputs.
Seems like a reasonable request. I'm thinking of a pseudo-element ::validation-message.
Reacted by Luiz Cieslak, Luis Sucuc, Marko Vujanic, Mohamed Ali Mejbar, AlexR, Yann, Ricardo, bcalou, Luis Romero, Luca Hostettler and 25 more
Reacted by Paul Shryock, Danny Feliz, Wisesa, KW, Sławomir Mendyka, Kat, Henry Blyth, Jurj Andrei George, Sebastian Zartner, Christian Schaefer and 2 more
Part of the issue (at least on Firefox's side) is that these popups live in a different process from the page (so we hit the same issues that limit styling of <select> options).
That said, there may be an argument to be made about these messages escaping the page's viewport not being so critical, and I know we've discussed moving them to the page's process at least once. Maybe these days they could just be user agent top layer magic or so... cc @smaug----.
With <select> is was trivial to find examples where a small iframe is used to show just the select element. I would expect the same here. So if a cross origin iframe has a simple form and you need to show validation message, where should that message live?
Just being able to set font-size: inherit or font-size: 1rem would go a long way. Currently, it’s impossible to increase the text size of error messages (AFAIK).
Define a new pseudo element ::error (name tbd) which represents the validation error popup that shows. This can be implemented using anchor positioning and popover (much like ::picker(select)). The text will default to what the browsers currently show but can be controlled via the content property. Using various state pseudo classes should be enough* to determine which text you want to display if you did want to override it statically, though you obviously could determine it in whatever way you wanted. E.g. setting a data-message attribute and using attr(data-message) in your CSS.
::error{appearance: base;/*To enable a standardised error box?*/content:"Some custom text";display: none;/*Can be used to remove the standard box entirely, useful if you want rich content*/}
Maybe also a new ::error::icon to control the icon that shows?
*Turns out there's not actually many pseudo classes related to input state see #1525 for possibly a step in that direction.
Using popover and anchor positioning (the arrow would even be doable with some of the anchor positioning enhancements planned), solves the security issue regarding escaping frames (much like it did for base select).
One thing that comes up is the desire to show these errors inline in the page. Like select listbox Vs combobox, where we might want author control of the behaviour. Perhaps a different appearance value? Perhaps a new property to control this?
We could also perhaps just have it so it's always in the Dom tree, and you can set display:block on it to make it visible (like you can a popover). Then you could make it so it's position: static and style it like normal?
Only issue then is how to make it so it only shows after validation runs and the browser decides it should render these. But perhaps that can be handled internally by the browser by default. But authors could make these render when :user-invalid?
Though the browser would move these into the top-layer when trying to open them, so that's probably not a good solution.
I would refrain from using content. Form validation message content can already be customized via .setCustomValidity. The rest seems like in the right direction?
Reacted by Luke Warlow, Masataka Yakura, Sam Atkins and Darren Hebner
One thing that comes up is the desire to show these errors inline in the page.
I think this would be very useful - but at the same time, being able to choose where in the DOM it appears would also likely be asked for; some design systems put errors before the field, some after, some inline.
Reacted by Yoav Weiss, Luke Warlow, Darren Hebner, Shauna Gordon, Oliver Williams and Adam Argyle
Which current CSS spec, if any, does this fit under? I wasn't sure, else I would have labelled it.
Perhaps css-forms?
Chromium currently implements validation bubbles as a popup document, which is the same thing we use for select popups and color picker popups. I am currently working on reimplementing them as in-document popovers for performance reasons.
I like Luke's idea and agree with Emilio's comment.
I think that using appearance:base to opt into a popover picker instead of a "native" browser one could address concerns about existing validation bubbles crossing boundaries like coming out of an iframe.
I didn't end up shipping my change to make all validation bubbles popovers due to lack of tether support (not sure what the current state of that is), and because I couldn't find a spot in the document to append a popover element for form-associated custom elements (for others like <input>, I put it in their user-agent shadowroot).
Another potential solution instead of adding a new pseudo-element would be a way to provide your own error popover, perhaps with some sort of idref to the form element:
<divpopoverid=errorpopover>
error message here
</div><inputrequiredvalidationmessage=errorpopover>
The CSS Working Group just discussed Give authors the ability to style form validation messages.
The full IRC log of that discussion
<keithamus> astearns: first item on agenda about styling form validation
<keithamus> jarhar: there's been some renewed interest in this feature lately
<keithamus> .. talked about at CSSDay, una could speak more on that
<una> q+
<keithamus> .. form validation bubbles aren't styleable at all right now. You can't change how the browser renders them
<keithamus> .. we have different ideas on how to make them more styleable, with a pseudo element
<keithamus> .. or the author could provide their own popover, and an idref association could allow you to provide your own validation bubble
<keithamus> .. so some potential API shapes
<masonf> q+
<lwarlow> q+
<keithamus> .. so interested in other implementers thoughts
<astearns> ack una
<smaug> q+
<keithamus> una: some context; developer research has told us this for many years. Many different conversations I could point to. I've been going back and forth on whether or not this is a good idea though.
<keithamus> una: this inability to style these - these messages that respond to a user input - the current browser UI gives an authority because it comes from a browser. Is this something we should give to developers to style?
<keithamus> .. there are other APIs that allow for developers to author these.
<keithamus> .. the problem is we end up with two bubbles - so maybe we want to think about how to disable the user agents bubbles
<astearns> ack masonf
<keithamus> .. but there's some stuff to discuss behind this, before we discuss a solution - how it might look like to solve this. Let's take a step back before we discuss what the shape of this might look like
<keithamus> masonf: one vote for me to be customisable. It's already in the developers hands as to whether or not form validation kicks in.
<keithamus> .. developers don't use this often anyway, and I presume it's because they don't match the site and they're inconsistent.
<keithamus> .. I don't know what the priority is though, but I think it's up ther.e
<keithamus> .. but to ask - jarhar you mentioned the "bring your own popover". How would one deliver the error message into the popover?
<keithamus> jarhar: we already have setValidationMessage where you can provide your own message, that's on the developer to localise. My rough idea with the popover is that it's an alternative to that, and so it's still on the author to localise it
<keithamus> masonf: localisation is a pain, so if we're trying to provide nice localised messages maybe that's a win
<astearns> ack lwarlow
<keithamus> smaug: possible privacy issues around the localised message... might be something
<keithamus> lwarlow: the nice thing with the error messages, they're not blocking us shipping in page controls. They're essentially a :picker style element.
<una> people do use these, because for example, if you just include a "required" attribute, you'll get an error message if the form entry is blank. This is a common pattern
<keithamus> lwarlow: but I do think it's important.
<keithamus> lwarlow: does the current browser approach actually match what authors want? Currently it shows a single error message and you have to change the field, then you might get a different one. Often I want a list of error messages.
<keithamus> lwarlow: if there was some way to get a list of those. CSS lacks pseudo classses for a bunch of states for example.
<una> q+
<keithamus> lwarlow: having the ability to style the browsers default popup is nice though. Leave most of it up to the browser - such as when it shows and such. If you do your own you can think about that, but styling the built-in could be a big win
<keithamus> lwarlow: Rolling your own might require more CSS for each validation state.
<smaug> q-
<keithamus> lwarlow: but it's something worth tackling. These aren't used very often so we should research how websites currently do this (without using this API).
<keithamus> lwarlow: for example when the input is blurred? User-valid vs user-invalid?
<keithamus> lwarlow: some more contextualised information
<keithamus> q+
<astearns> ack una
<keithamus> una: people _do use these_. required on a form - when you hit submit you'll see it. It's a common use case, especially when copy/pasting example forms.
<keithamus> una: its interesting that when you have access to the error message... that might be something useful to store
<keithamus> .. there's a security issue - we don't want the developer to change the error message... or maybe we do?
<keithamus> .. if it's a generalised required field it would be handy to have the error immutable message to display
<lwarlow> q+
<keithamus> .. we could customise the popover - it's an interesting idea - but when there is some kind of form error message it applies accurately. We don't want an error message for "this field is empty" to become "you must write your social security number here".
<keithamus> .. maybe if there's a way to preserve the list of error messages from the user agent.
<lwarlow> We already have setCustomValidity for that right?
<astearns> ack keithamus
<masonf> keithamus: I don't necessarily buy the security argument. There's not a lot to inform the user that this is coming from the browser.
<masonf> keithamus: that's a contentious reasoning at best. We (in this room) understand what's browser UI and what isn't. Users don't.
<masonf> keithamus: There's a large spectrum between most users understanding of these things. E.g. the line of death isn't well understood.
<masonf> keithamus: The main takeaway is "why not both?"
<masonf> keithamus: to use the baked-in UI, give them small customization. For power developers, give them the popover. The less work we can make it, the better.
<masonf> keithamus: Middle-ground between no customizability, and full custom. Maybe appearance:base on the pseudo would be enough for many.
<masonf> keithamus: One last thing: we should be very careful talking about how messages are displayed, and timing of user interaction. There are a11y criteria - e.g. displaying all error messages at the same time isn't always great.
<masonf> keithamus: we should explore existing design space. Perhaps in OpenUI we can work on this more.
<astearns> ack lwarlow
<keithamus> lwarlow: three things; it would be interesting if you replaced the markup, does it have to be a popover? Some people might prefer it to be in the page.
<keithamus> q+
<keithamus> lwarlow: I think this is an area where a lot of people want different things. Some want to leave it to the browser, some replace the styling, and some want to replace the text entirely.
<keithamus> .. it might be technically correct but not actually correct as people would use it
<keithamus> .. you can override using setCustomValidity but you lose localisation
<keithamus> .. the localisation the browser provides is a big part of why people continue to use these.
<keithamus> .. I've heard people say they want access to these strings.
<keithamus> .. I'm curious - smaug you're concerns about the strings?
<jarhar> according to the mdn article, validationMessage is already localized: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/validationMessage
<keithamus> smaug: you're exposing a lot of information about the language
<keithamus> lwarlow: don't we already expose this in a header?
<keithamus> smaug: you might have a very minor locale you're using
<keithamus> lwarlow: but don't browsers send a header?
<keithamus> keithamus: but the browsers can lie
<keithamus> lwarlow: fair. You can allow the browsers to lie for the locale string then?
<keithamus> masonf: correct me if I am wrong but if you expose the string itself you could probably probe for locale
<keithamus> lwarlow: yeah essentially match the string to what the browser is saying
<keithamus> smaug: whatever we do here, if we expose something it's not exposed currently. So we need to run it past privacy folks.
<keithamus> lwarlow: that's something that needs considering, but the styling can still work - and if you want something more then you're taking localisation into your own hands
<keithamus> lwarlow: the browser UI using anchoring positioning, we need the ability to tether if we want to replicate the browser UI
<keithamus> lwarlow: currently you don't have that information available to you.
<astearns> ack keithamus
<keithamus> .. people want that anyway so browser folks go build it!
<masonf> keithamus: The locale - we can potentially get rid of privacy issues by using one language, or normalizing to common locale or something.
<una> q+
<masonf> keithamus: there are things that the browser presents that are - e.g. there's the pattern attribute. The browser will come up with a message that says "must match the pattern" but the developer knows more and can provide a better error message.
<lwarlow> q+
<masonf> keithamus: coming back to the spectrum - there are some that need a well curated set of messages.
<astearns> ack una
<keithamus> una: so what if you have a form field that has different types of errors? What if it requires numbers and you put letters in
<keithamus> una: how does a developer specify what those errors are?
<keithamus> lwarlow: more css pseudo classes for the validation would be good. A lot isn't exposed, or not exposed in a granular enough way.
<keithamus> lwarlow: it's also part of the UX issue, it's an ordering issue, first it'll tell you it's required, then it'll tell you the pattern is wrong. but with multiple pseudo classes you could apply multiple error messages together.
<keithamus> una: you're envisioning a set of states, required error, pattern match error, and you'd "and" them together?
<keithamus> lwarlow: you'd build lists, hide each item based on the pseudo state.
<keithamus> lwarlow: I left a comment on one of the css issues.
<keithamus> keithamus: https://developer.mozilla.org/en-US/docs/Web/API/ValidityState this API exists in JS, wholesale in CSS could be good
<keithamus> lwarlow: overriding content css property on the pseudo elements. If you had that then you could go and fix the error messages.
<keithamus> lwarlow: I could replace specific error messages when I need to
<keithamus> lwarlow: and if I am localising then I would be localising all my string anyway
<astearns> ack lwarlow
<keithamus> astearns: I like the idea of having openui do a survey on error messages
<smaug> FWIW, I think https://searchfox.org/mozilla-central/rev/1eb4f27ece7cb96ac94b635ad0dc95c00d1443db/dom/locales/en-US/chrome/dom/dom.properties#37-68 is the list of localized error messages.
<keithamus> q+
<fantasai> I think content belongs in the HTML, not the CSS.
<lwarlow> https://github.com//issues/1525 - this is the CSSWG issue I mentioned about exposing pseudo class(es)
<keithamus> astearns: what design systems to do override these things
<keithamus> astearns: then having a granular list of what we might want to do here.
<bkardell> fantasai: I think I agree, but how would you put it in?
<smaug> (and I see up to 99 different locales for those error messages for Firefox )
<keithamus> astearns: multiple things: changing the error message, concatenating, changing wholesale the error message display. Each of these might have privacy and security issues, when we figure out what we might want to do we can involve those folks.
<astearns> ack keithamus
<astearns> s/privacy and security/privacy and security and accessibility/
<masonf> keithamus: a lot of the form validation stuff is fundamentally broken - several open issues. Rolling custom validity messages - not able to listen to events for validity states. So even people who are trying to use this API end up having to roll their own anyway.
<lwarlow> Here's an example of a missing custom element hook https://github.com/whatwg/html/issues/9878
<masonf> keithamus: we can do some simple things to get 80% of the way there. Let's do the easy stuff first, and then talk about the advanced things.
<fantasai> <error type=pattern inputclass=something>Error Message Here</error> ... <input patternerror=something> ... <input patternerror=something> ...
<bkardell> smaug: that is what I was thinking about too
<fantasai> bkardell: ^
<keithamus> Some issues for the basics; https://github.com/whatwg/html/issues/10694, https://github.com/whatwg/html/issues/4280, https://github.com/whatwg/html/issues/9878
<bkardell> fantasai: see what Smaug said though
<lwarlow> +1 to taking this back to OpenUI
<keithamus> masonf: the privacy question seems key to several of the solutions, so maybe we should get that going
<keithamus> astearns: getting an accessibility story behind these would be good. What should we be concerned about here?
<keithamus> astearns: anything more on this today?
<bkardell> +1
<keithamus> astearns: anyone volunteering to take this back to openUI?
<keithamus> keithamus: i will
didn't end up shipping my change to make all validation bubbles popovers due to lack of tether support (not sure what the current state of that is), and because
couldn't find a spot in the document to append a popover element for form-
associated custom elements (for others like , Iput it in their user-agent shadowroot).
Tether I think should be accounted for by the new anchored container queries right?
As for where to put the error popover for custom elements would the form element be a possible place? It's not allowed an author shadow root so the UA is free to add one. The popover will be positioned via anchor positioning and so the Dom location is irrelevant. Could that work?
As for where to put the error popover for custom elements would the form element be a possible place? It's not allowed an author shadow root so the UA is free to add one. The popover will be positioned via anchor positioning and so the Dom location is irrelevant. Could that work?
Thanks for the idea! Is it not possible to trigger validation for a form-associated custom element that isn't in a form?
In that case is a shadowroot on the html element itself an awful idea? Without somewhere for the UA to put them in the document it's going to be iffy with any pseudo-element based styling in future?
I do wonder if making them popovers for appearance:auto might be problematic for compat, the same way making selects not be able to escape the window would be an issue for some small iframes. Ultimately that's up to chromium if you want to try that bit either way we'll need a solution to this issue.
Very powerful since the author provides all their own markup, don't have to worry about providing a way to change the icon.
Easier to implement, don't have to worry about finding a place to put the popover for a form-associated custom element for example.
I don't see these as mutually exclusive. The pseudo-element makes simple things easy, the <error> element makes complex things possible. Same as tooltips: ::tooltip for styling the simple native tooltips, interest invokers for rich custom tooltips. If you only need styling you should be able to just do styling, you shouldn't have to provide custom UI.
Activity
emilio commentedon Mar 25, 2022
Part of the issue (at least on Firefox's side) is that these popups live in a different process from the page (so we hit the same issues that limit styling of
<select>options).That said, there may be an argument to be made about these messages escaping the page's viewport not being so critical, and I know we've discussed moving them to the page's process at least once. Maybe these days they could just be user agent top layer magic or so... cc @smaug----.
smaug---- commentedon Apr 24, 2022
With
<select>is was trivial to find examples where a small iframe is used to show just the select element. I would expect the same here. So if a cross origin iframe has a simple form and you need to show validation message, where should that message live?simevidas commentedon May 6, 2023
Just being able to set
font-size: inheritorfont-size: 1remwould go a long way. Currently, it’s impossible to increase the text size of error messages (AFAIK).fantasai commentedon Jan 9, 2024
Some related CSSWG discussion: https://lists.w3.org/Archives/Public/www-style/2023Sep/0020.html
svgeesus commentedon Jul 15, 2024
Which current CSS spec, if any, does this fit under? I wasn't sure, else I would have labelled it.
lukewarlow commentedon Mar 5, 2025
A quick note down of a potential solution.
Define a new pseudo element
::error(name tbd) which represents the validation error popup that shows. This can be implemented using anchor positioning and popover (much like::picker(select)). The text will default to what the browsers currently show but can be controlled via the content property. Using various state pseudo classes should be enough* to determine which text you want to display if you did want to override it statically, though you obviously could determine it in whatever way you wanted. E.g. setting a data-message attribute and using attr(data-message) in your CSS.Maybe also a new ::error::icon to control the icon that shows?
*Turns out there's not actually many pseudo classes related to input state see #1525 for possibly a step in that direction.
Using popover and anchor positioning (the arrow would even be doable with some of the anchor positioning enhancements planned), solves the security issue regarding escaping frames (much like it did for base select).
One thing that comes up is the desire to show these errors inline in the page. Like select listbox Vs combobox, where we might want author control of the behaviour. Perhaps a different appearance value? Perhaps a new property to control this?
We could also perhaps just have it so it's always in the Dom tree, and you can set display:block on it to make it visible (like you can a popover). Then you could make it so it's position: static and style it like normal?
Only issue then is how to make it so it only shows after validation runs and the browser decides it should render these. But perhaps that can be handled internally by the browser by default. But authors could make these render when :user-invalid?
Though the browser would move these into the top-layer when trying to open them, so that's probably not a good solution.
emilio commentedon Mar 5, 2025
I would refrain from using
content. Form validation message content can already be customized via.setCustomValidity. The rest seems like in the right direction?frehner commentedon Mar 10, 2025
I think this would be very useful - but at the same time, being able to choose where in the DOM it appears would also likely be asked for; some design systems put errors before the field, some after, some inline.
josepharhar commentedon Mar 13, 2025
Perhaps css-forms?
Chromium currently implements validation bubbles as a popup document, which is the same thing we use for select popups and color picker popups. I am currently working on reimplementing them as in-document popovers for performance reasons.
josepharhar commentedon Jul 7, 2025
I like Luke's idea and agree with Emilio's comment.
I think that using appearance:base to opt into a popover picker instead of a "native" browser one could address concerns about existing validation bubbles crossing boundaries like coming out of an iframe.
I didn't end up shipping my change to make all validation bubbles popovers due to lack of tether support (not sure what the current state of that is), and because I couldn't find a spot in the document to append a popover element for form-associated custom elements (for others like
<input>, I put it in their user-agent shadowroot).josepharhar commentedon Jul 10, 2025
Another potential solution instead of adding a new pseudo-element would be a way to provide your own error popover, perhaps with some sort of idref to the form element:
css-meeting-bot commentedon Jul 10, 2025
The CSS Working Group just discussed
Give authors the ability to style form validation messages.The full IRC log of that discussion
<keithamus> astearns: first item on agenda about styling form validation<keithamus> jarhar: there's been some renewed interest in this feature lately
<keithamus> .. talked about at CSSDay, una could speak more on that
<una> q+
<keithamus> .. form validation bubbles aren't styleable at all right now. You can't change how the browser renders them
<keithamus> .. we have different ideas on how to make them more styleable, with a pseudo element
<keithamus> .. or the author could provide their own popover, and an idref association could allow you to provide your own validation bubble
<keithamus> .. so some potential API shapes
<masonf> q+
<lwarlow> q+
<keithamus> .. so interested in other implementers thoughts
<astearns> ack una
<smaug> q+
<keithamus> una: some context; developer research has told us this for many years. Many different conversations I could point to. I've been going back and forth on whether or not this is a good idea though.
<keithamus> una: this inability to style these - these messages that respond to a user input - the current browser UI gives an authority because it comes from a browser. Is this something we should give to developers to style?
<keithamus> .. there are other APIs that allow for developers to author these.
<keithamus> .. the problem is we end up with two bubbles - so maybe we want to think about how to disable the user agents bubbles
<astearns> ack masonf
<keithamus> .. but there's some stuff to discuss behind this, before we discuss a solution - how it might look like to solve this. Let's take a step back before we discuss what the shape of this might look like
<keithamus> masonf: one vote for me to be customisable. It's already in the developers hands as to whether or not form validation kicks in.
<keithamus> .. developers don't use this often anyway, and I presume it's because they don't match the site and they're inconsistent.
<keithamus> .. I don't know what the priority is though, but I think it's up ther.e
<keithamus> .. but to ask - jarhar you mentioned the "bring your own popover". How would one deliver the error message into the popover?
<keithamus> jarhar: we already have setValidationMessage where you can provide your own message, that's on the developer to localise. My rough idea with the popover is that it's an alternative to that, and so it's still on the author to localise it
<keithamus> masonf: localisation is a pain, so if we're trying to provide nice localised messages maybe that's a win
<astearns> ack lwarlow
<keithamus> smaug: possible privacy issues around the localised message... might be something
<keithamus> lwarlow: the nice thing with the error messages, they're not blocking us shipping in page controls. They're essentially a :picker style element.
<una> people do use these, because for example, if you just include a "required" attribute, you'll get an error message if the form entry is blank. This is a common pattern
<keithamus> lwarlow: but I do think it's important.
<keithamus> lwarlow: does the current browser approach actually match what authors want? Currently it shows a single error message and you have to change the field, then you might get a different one. Often I want a list of error messages.
<keithamus> lwarlow: if there was some way to get a list of those. CSS lacks pseudo classses for a bunch of states for example.
<una> q+
<keithamus> lwarlow: having the ability to style the browsers default popup is nice though. Leave most of it up to the browser - such as when it shows and such. If you do your own you can think about that, but styling the built-in could be a big win
<keithamus> lwarlow: Rolling your own might require more CSS for each validation state.
<smaug> q-
<keithamus> lwarlow: but it's something worth tackling. These aren't used very often so we should research how websites currently do this (without using this API).
<keithamus> lwarlow: for example when the input is blurred? User-valid vs user-invalid?
<keithamus> lwarlow: some more contextualised information
<keithamus> q+
<astearns> ack una
<keithamus> una: people _do use these_. required on a form - when you hit submit you'll see it. It's a common use case, especially when copy/pasting example forms.
<keithamus> una: its interesting that when you have access to the error message... that might be something useful to store
<keithamus> .. there's a security issue - we don't want the developer to change the error message... or maybe we do?
<keithamus> .. if it's a generalised required field it would be handy to have the error immutable message to display
<lwarlow> q+
<keithamus> .. we could customise the popover - it's an interesting idea - but when there is some kind of form error message it applies accurately. We don't want an error message for "this field is empty" to become "you must write your social security number here".
<keithamus> .. maybe if there's a way to preserve the list of error messages from the user agent.
<lwarlow> We already have setCustomValidity for that right?
<astearns> ack keithamus
<masonf> keithamus: I don't necessarily buy the security argument. There's not a lot to inform the user that this is coming from the browser.
<masonf> keithamus: that's a contentious reasoning at best. We (in this room) understand what's browser UI and what isn't. Users don't.
<masonf> keithamus: There's a large spectrum between most users understanding of these things. E.g. the line of death isn't well understood.
<masonf> keithamus: The main takeaway is "why not both?"
<masonf> keithamus: to use the baked-in UI, give them small customization. For power developers, give them the popover. The less work we can make it, the better.
<masonf> keithamus: Middle-ground between no customizability, and full custom. Maybe appearance:base on the pseudo would be enough for many.
<masonf> keithamus: One last thing: we should be very careful talking about how messages are displayed, and timing of user interaction. There are a11y criteria - e.g. displaying all error messages at the same time isn't always great.
<masonf> keithamus: we should explore existing design space. Perhaps in OpenUI we can work on this more.
<astearns> ack lwarlow
<keithamus> lwarlow: three things; it would be interesting if you replaced the markup, does it have to be a popover? Some people might prefer it to be in the page.
<keithamus> q+
<keithamus> lwarlow: I think this is an area where a lot of people want different things. Some want to leave it to the browser, some replace the styling, and some want to replace the text entirely.
<keithamus> .. it might be technically correct but not actually correct as people would use it
<keithamus> .. you can override using setCustomValidity but you lose localisation
<keithamus> .. the localisation the browser provides is a big part of why people continue to use these.
<keithamus> .. I've heard people say they want access to these strings.
<keithamus> .. I'm curious - smaug you're concerns about the strings?
<jarhar> according to the mdn article, validationMessage is already localized: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/validationMessage
<keithamus> smaug: you're exposing a lot of information about the language
<keithamus> lwarlow: don't we already expose this in a header?
<keithamus> smaug: you might have a very minor locale you're using
<keithamus> lwarlow: but don't browsers send a header?
<keithamus> keithamus: but the browsers can lie
<keithamus> lwarlow: fair. You can allow the browsers to lie for the locale string then?
<keithamus> masonf: correct me if I am wrong but if you expose the string itself you could probably probe for locale
<keithamus> lwarlow: yeah essentially match the string to what the browser is saying
<keithamus> smaug: whatever we do here, if we expose something it's not exposed currently. So we need to run it past privacy folks.
<keithamus> lwarlow: that's something that needs considering, but the styling can still work - and if you want something more then you're taking localisation into your own hands
<keithamus> lwarlow: the browser UI using anchoring positioning, we need the ability to tether if we want to replicate the browser UI
<keithamus> lwarlow: currently you don't have that information available to you.
<astearns> ack keithamus
<keithamus> .. people want that anyway so browser folks go build it!
<masonf> keithamus: The locale - we can potentially get rid of privacy issues by using one language, or normalizing to common locale or something.
<una> q+
<masonf> keithamus: there are things that the browser presents that are - e.g. there's the pattern attribute. The browser will come up with a message that says "must match the pattern" but the developer knows more and can provide a better error message.
<lwarlow> q+
<masonf> keithamus: coming back to the spectrum - there are some that need a well curated set of messages.
<astearns> ack una
<keithamus> una: so what if you have a form field that has different types of errors? What if it requires numbers and you put letters in
<keithamus> una: how does a developer specify what those errors are?
<keithamus> lwarlow: more css pseudo classes for the validation would be good. A lot isn't exposed, or not exposed in a granular enough way.
<keithamus> lwarlow: it's also part of the UX issue, it's an ordering issue, first it'll tell you it's required, then it'll tell you the pattern is wrong. but with multiple pseudo classes you could apply multiple error messages together.
<keithamus> una: you're envisioning a set of states, required error, pattern match error, and you'd "and" them together?
<keithamus> lwarlow: you'd build lists, hide each item based on the pseudo state.
<keithamus> lwarlow: I left a comment on one of the css issues.
<keithamus> keithamus: https://developer.mozilla.org/en-US/docs/Web/API/ValidityState this API exists in JS, wholesale in CSS could be good
<keithamus> lwarlow: overriding content css property on the pseudo elements. If you had that then you could go and fix the error messages.
<keithamus> lwarlow: I could replace specific error messages when I need to
<keithamus> lwarlow: and if I am localising then I would be localising all my string anyway
<astearns> ack lwarlow
<keithamus> astearns: I like the idea of having openui do a survey on error messages
<smaug> FWIW, I think https://searchfox.org/mozilla-central/rev/1eb4f27ece7cb96ac94b635ad0dc95c00d1443db/dom/locales/en-US/chrome/dom/dom.properties#37-68 is the list of localized error messages.
<keithamus> q+
<fantasai> I think content belongs in the HTML, not the CSS.
<lwarlow> https://github.com//issues/1525 - this is the CSSWG issue I mentioned about exposing pseudo class(es)
<keithamus> astearns: what design systems to do override these things
<keithamus> astearns: then having a granular list of what we might want to do here.
<bkardell> fantasai: I think I agree, but how would you put it in?
<smaug> (and I see up to 99 different locales for those error messages for Firefox )
<keithamus> astearns: multiple things: changing the error message, concatenating, changing wholesale the error message display. Each of these might have privacy and security issues, when we figure out what we might want to do we can involve those folks.
<astearns> ack keithamus
<astearns> s/privacy and security/privacy and security and accessibility/
<masonf> keithamus: a lot of the form validation stuff is fundamentally broken - several open issues. Rolling custom validity messages - not able to listen to events for validity states. So even people who are trying to use this API end up having to roll their own anyway.
<lwarlow> Here's an example of a missing custom element hook https://github.com/whatwg/html/issues/9878
<masonf> keithamus: we can do some simple things to get 80% of the way there. Let's do the easy stuff first, and then talk about the advanced things.
<fantasai> <error type=pattern inputclass=something>Error Message Here</error> ... <input patternerror=something> ... <input patternerror=something> ...
<bkardell> smaug: that is what I was thinking about too
<fantasai> bkardell: ^
<keithamus> Some issues for the basics; https://github.com/whatwg/html/issues/10694, https://github.com/whatwg/html/issues/4280, https://github.com/whatwg/html/issues/9878
<bkardell> fantasai: see what Smaug said though
<lwarlow> +1 to taking this back to OpenUI
<keithamus> masonf: the privacy question seems key to several of the solutions, so maybe we should get that going
<keithamus> astearns: getting an accessibility story behind these would be good. What should we be concerned about here?
<keithamus> astearns: anything more on this today?
<bkardell> +1
<keithamus> astearns: anyone volunteering to take this back to openUI?
<keithamus> keithamus: i will
josepharhar commentedon Jul 10, 2025
Pros of pseudo-element:
Pros of providing your own popover:
lukewarlow commentedon Oct 6, 2025
Tether I think should be accounted for by the new anchored container queries right?
As for where to put the error popover for custom elements would the form element be a possible place? It's not allowed an author shadow root so the UA is free to add one. The popover will be positioned via anchor positioning and so the Dom location is irrelevant. Could that work?
josepharhar commentedon Oct 7, 2025
Thanks for the idea! Is it not possible to trigger validation for a form-associated custom element that isn't in a form?
lukewarlow commentedon Oct 7, 2025
Is it possible to do for an input that's not form associated (child of form or using form attribute)?
If that's possible it'd rule my idea out, I thought it required a form though?
josepharhar commentedon Oct 7, 2025
Here is an example which creates a validation bubble with no form element: https://codepen.io/jarhar/pen/wBMJZVx
lukewarlow commentedon Oct 7, 2025
In that case is a shadowroot on the html element itself an awful idea? Without somewhere for the UA to put them in the document it's going to be iffy with any pseudo-element based styling in future?
I do wonder if making them popovers for appearance:auto might be problematic for compat, the same way making selects not be able to escape the window would be an issue for some small iframes. Ultimately that's up to chromium if you want to try that bit either way we'll need a solution to this issue.
LeaVerou commentedon Nov 20, 2026
I don't see these as mutually exclusive. The pseudo-element makes simple things easy, the
<error>element makes complex things possible. Same as tooltips:::tooltipfor styling the simple native tooltips, interest invokers for rich custom tooltips. If you only need styling you should be able to just do styling, you shouldn't have to provide custom UI.