Att Input Alt
# HTML alt Attribute
The `alt` attribute of the `` tag is used to provide an alternate text description for an image input button. This text is displayed if the image cannot be loaded or if the user is using assistive technologies like screen readers.
---
## Definition and Usage
The `alt` attribute specifies an alternate text for an image input button (i.e., ``).
This alternate text is crucial for web accessibility and user experience. It is displayed to the user when:
* The connection is slow or the image fails to load (due to an incorrect path in the `src` attribute).
* The user has disabled image loading in their browser.
* The user is visually impaired and relies on a screen reader to read the page content aloud.
> **Important Note:** The `alt` attribute can **only** be used when the `type` attribute of the `` element is set to `"image"`. Using it with other input types (such as `text`, `submit`, or `button`) has no effect.
---
## Browser Support
The `alt` attribute is fully supported by all major modern web browsers:
* Google Chrome
* Mozilla Firefox
* Microsoft Edge / Internet Explorer
* Safari
* Opera
---
## Syntax
```html
```
### Attribute Values
| Value | Description |
| :--- | :--- |
| *text* | Specifies the alternative text for the image input button. |
---
## Code Examples
### Example 1: Standard Image Submit Button
Below is a standard HTML form that uses an image as a submit button. If the image `submit.gif` fails to load, the browser will display the text "Submit" instead.
```html
```
---
## HTML 4.01 vs. HTML5
There are no functional differences in how the `alt` attribute behaves between HTML 4.01 and HTML5. However, in modern HTML5 development, ensuring proper `alt` attributes is highly emphasized for compliance with web accessibility standards (such as WCAG).
---
## Best Practices and Considerations
1. **Always Provide Meaningful Text:** The `alt` text should clearly describe the action of the button (e.g., "Submit", "Search", "Login") rather than describing the visual appearance of the image (e.g., "Blue arrow button").
2. **Keep it Concise:** Keep the alternate text short and direct.
3. **Do Not Omit for Image Inputs:** Unlike standard decorative `
` tags where an empty `alt=""` is sometimes acceptable, an `` is an interactive control and **must** always have a descriptive `alt` value so screen reader users know what the button does.
YouTip