Search code examples
htmlfirefoxattributeshidealt

hide alt tag in firefox


As per the default behavior, alt attribute is rendered first time just before the image rendering. I am displaying 25 images in a grid so it looks bit awkward as all alt attributes are displayed first.

Is it possible to hide alt attributes in Firefox?

Note: alt attributes contain dynamic names in my case.


Solution

  • The way to prevent alt attribute values from being displayed is to remove the attribute.

    The meaning of an alt attribute (not tag) is that it specifies an alternative, a substitute for the image, in situations where the image is not displayed. So if you want to hide it when the image has not yet been loaded, you are asking for behavior that contradicts the very meaning of the attribute.

    You can however make the alt text invisible (with the usual CSS Caveats) on Firefox by setting e.g.

    img { background: white; color: white; }
    

    in CSS. This implies that the alt texts are invisible also in case the browser never gets the image, or the browser has been configured not to display images.