HTML Standard attribute: alt
[this page | pdf | back links]
The HTML alt attribute indicates the
alternative text to show when original content (e.g. an image) fails to
display. It applies to <area>,
<img> and <input>
elements.
There are several possible reasons why an image might not
display, e.g. there might be a slow connection, the content location might be
wrongly specified or the user might be using a screen reader because he or she
is partly sighted). Some old browsers showed the value of the alt attribute as a tooltip, but modern
browsers use the title
attribute instead for this purpose.
Valid attribute
values (when used with <area>, <img> and <input>
elements) include:
Value
|
Description
|
text
|
Alternative text to
display
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Set using HTML:<br>
<img alt="can't find file" src="Pictures/Shape1.jpg"><br>
<img alt="can't find file" src="Pictures/Missing.jpg"><br>
<br><br>Set using JavaScript:<br>
<img alt="can't find file" src="Pictures/Missing.jpg"><br>
<script>
var att = document.createAttribute("alt");
att.value = "can't find file";
document.getElementById("x1").setAttributeNode(att);
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes