Hiding Broken Images in HTML

A nice write-up on styling broken images has appeared online by bitsofco.de 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="this.style.display='none'" />

Related Content

Published on