Skip to content

Hiding Broken Images in HTML

1 min read

A nice write-up on styling broken images has appeared online by in the last 24 hours; however, if you want a simple way of completely hiding a broken image you can just use the onerror attribute of the <img /> tag to hide the image element like this:-

<img src="broken.png" onerror="'none'" />
© 2024 Andy Carter