HTML img alt Attribute
HTML <img> tag
Definition and Usage
The alt attribute should be a short description of the image
This attribute is used when the user for some reason cannot see the image.
This could be because of a slow connection, an error in the image URL, or the
user could be using a text-only or non-visual browsers.
Syntax
Syntax Example
<img alt="W3Schools example picture" />
|
Attribute Values
Value |
Description |
type |
A short description of the image. Guidelines for
the alt text:
- If the image contains important information - use the attribute
to describe the image.
- If the image is a link (inside an "<a>" element) - use the
attribute to explain the link (like url and target frame)
- If the image is not informative (only for decoration) - Use an
empty alt attribute (like alt="")
Note: Not using the alt attribute will cause problems for
text-only browsers or non-visual browsers. |
Browser Support

The attribute is supported in all major browsers.
Example
Source |
Output |
<img src="demo_img.jpg"
alt="W3Schools example picture" />
|
|
Try-It-Yourself Demos
img alt
attribute example
Specify an alternate text for the image.
HTML <img> tag
Whether you're new to XML or already an advanced user, the user-friendly views
and powerful entry helpers, wizards, and debuggers in XMLSpy are designed to
meet your XML and Web services development needs from start to finish.
- XML editor
- Graphical XML Schema / DTD editors
- XSLT 1.0/2.0 editor, debugger, profiler
- XQuery editor, debugger, profiler
- Support for Office Open XML (OOXML)
- Graphical WSDL editor & SOAP debugger
- Java, C#, C++ code generation
- And much more!
Download a fully functional free 30-day trial today!
|