Well, this one blew my mind completely when I got to know about it. So, you probably are aware of the fact that the tag is used for displaying images on websites.
The thing is, you can set an onerror event handler on the image that will trigger an https://developer.mozilla.org/en-US/docs/Web/API/Element/error_event If an error occurs while loading or rendering an image. So, you can use this to your advantage and hide the image completely if the browser is not able to render it like so.
So, when the image is not loaded, the browser will show the alt text.