Basically I want something like this, <img src="doesntexist.png alt="Image does <b>Not</b> exist" />
.
Edit Thanks for the info, but I was hoping to accomplish this without JavaScript.
You can't do what you're asking with traditional HTML.
The alt attribute is defined in a set of tags (namely, img, area and optionally for input and applet) to allow you to provide a text equivalent for the object.
http://www.w3.org/QA/Tips/altAttribute
Alt attributes are used to display a text description of an image whenever the image is not available, is not displayed by the browser, or the image cannot be seen by the user. Some users can be blind, color-blind, or low-sighted. The alt attribute is used in such cases to aid users by describing the intent of the image.
You might want to look into something like a tooltip. With tooltips you can customize the style and how they appear to the end user. There are a bunch of them out there. One example is jQuery's Tooltip: http://jqueryui.com/tooltip/#custom-style
Unfortunately no. It can however be replicated to allow markup with Javascript.
function altContent(img) {
var alt = document.createElement('div');
alt.innerHTML = img.getAttribute('alt');
img.parentNode.replaceChild(alt, img);
}
Then just add the attribute onerror
to the image, like so.
<img src="doesntexist.png alt="Image does <b>Not</b> exist" onerror="altContent(this)" />