[html] Inputting a default image in case the src attribute of an html <img> is not valid?

An HTML only solution, where the only requirement is that you know the size of the image that you're inserting. Will not work for transparent images, as it uses background-image as a filler.

We can successfully use background-image to link the image that appears if the given image is missing. Then the only problem is the broken icon image - we can remove it by inserting a very big empty character, thus pushing the content outside the display of img.

_x000D_
_x000D_
img {_x000D_
  background-image: url("http://placehold.it/200x200");_x000D_
  overflow: hidden;_x000D_
}_x000D_
_x000D_
img:before {_x000D_
  content: " ";_x000D_
  font-size: 1000px;_x000D_
}
_x000D_
This image is missing:_x000D_
<img src="a.jpg" style="width: 200px; height: 200px"/><br/>_x000D_
And is displaying the placeholder
_x000D_
_x000D_
_x000D_


An CSS only solution (Webkit only)

_x000D_
_x000D_
img:before {_x000D_
  content: " ";_x000D_
  font-size: 1000px;_x000D_
  background-image: url("http://placehold.it/200x200");_x000D_
  display: block;_x000D_
  width: 200px;_x000D_
  height: 200px;_x000D_
  position: relative;_x000D_
  z-index: 0;_x000D_
  margin-bottom: -16px;_x000D_
}
_x000D_
This image is there:_x000D_
<img src="http://placehold.it/100x100"/><br/>_x000D_
_x000D_
This image is missing:_x000D_
<img src="a.jpg"/><br/>_x000D_
And is displaying the placeholder
_x000D_
_x000D_
_x000D_