t - Web APIs | MDN
Có thể bạn quan tâm
- Skip to main content
- Skip to search
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
- Learn more
- See full compatibility
- Report feedback
The alt property of the HTMLImageElement interface provides fallback (alternate) text to display when the image specified by the <img> element is not displayed, whether because of an error, because the user has disabled the loading of images, or because the image hasn't finished loading yet. It reflects the <img> element's alt content attribute.
There are important accessibility implications of providing appropriate alt text, and the requirements may differ based on the purpose of the image. See the HTML <img> reference for more information.
In this article
- Value
- Examples
- Specifications
- Browser compatibility
Value
A string.
Examples
Setting the alt attribute
jsconst img = new Image(); img.src = "example.png"; img.alt = "An example picture";Specifications
| Specification |
|---|
| HTML# dom-img-alt |
Browser compatibility
Help improve MDN
Was this page helpful to you? Yes No Learn how to contributeThis page was last modified on Nov 7, 2025 by MDN contributors.
View this page on GitHub • Report a problem with this content Filter sidebar- The HTML DOM API
- HTMLImageElement
- Constructor
- Image()
- Instance properties
- align Deprecated
- alt
- attributionSrc Deprecated
- border Deprecated
- complete
- crossOrigin
- currentSrc
- decoding
- fetchPriority
- height
- hspace Deprecated
- isMap
- loading
- longDesc Deprecated
- name Deprecated
- naturalHeight
- naturalWidth
- referrerPolicy
- sizes
- src
- srcset
- useMap
- vspace Deprecated
- width
- x
- y
- Instance methods
- decode()
- Inheritance
- HTMLElement
- Element
- Node
- EventTarget
- Related pages for HTML DOM
- BeforeUnloadEvent
- DOMStringMap
- ErrorEvent
- HTMLAnchorElement
- HTMLAreaElement
- HTMLAudioElement
- HTMLBRElement
- HTMLBaseElement
- HTMLBodyElement
- HTMLButtonElement
- HTMLCanvasElement
- HTMLDListElement
- HTMLDataElement
- HTMLDataListElement
- HTMLDialogElement
- HTMLDivElement
- HTMLDocument
- HTMLElement
- HTMLEmbedElement
- HTMLFieldSetElement
- HTMLFormControlsCollection
- HTMLFormElement
- HTMLFrameSetElement Deprecated
- HTMLHRElement
- HTMLHeadElement
- HTMLHeadingElement
- HTMLHtmlElement
- HTMLIFrameElement
- HTMLInputElement
- HTMLLIElement
- HTMLLabelElement
- HTMLLegendElement
- HTMLLinkElement
- HTMLMapElement
- HTMLMediaElement
- HTMLMenuElement
- HTMLMetaElement
- HTMLMeterElement
- HTMLModElement
- HTMLOListElement
- HTMLObjectElement
- HTMLOptGroupElement
- HTMLOptionElement
- HTMLOptionsCollection
- HTMLOutputElement
- HTMLParagraphElement
- HTMLPictureElement
- HTMLPreElement
- HTMLProgressElement
- HTMLQuoteElement
- HTMLScriptElement
- HTMLSelectElement
- HTMLSourceElement
- HTMLSpanElement
- HTMLStyleElement
- HTMLTableCaptionElement
- HTMLTableCellElement
- HTMLTableColElement
- HTMLTableElement
- HTMLTableRowElement
- HTMLTableSectionElement
- HTMLTemplateElement
- HTMLTextAreaElement
- HTMLTimeElement
- HTMLTitleElement
- HTMLTrackElement
- HTMLUListElement
- HTMLUnknownElement
- HTMLVideoElement
- HashChangeEvent
- History
- ImageData
- Location
- MessageChannel
- MessageEvent
- MessagePort
- Navigator
- PageRevealEvent
- PageSwapEvent
- PageTransitionEvent
- Plugin Deprecated
- PluginArray Deprecated
- PromiseRejectionEvent
- RadioNodeList
- TimeRanges
- UserActivation
- ValidityState
- Window
- WorkletGlobalScope
- Guides
- Using microtasks in JavaScript with queueMicrotask()
- In depth: Microtasks and the JavaScript runtime environment
Từ khóa » Html Alt Text For Buttons
-
Can The Alt Attribute Be Used For An Input Type Button - Stack Overflow
-
HTML Input Alt Attribute - W3Schools
-
Image Buttons Must Have Alternate Text Axe Rules - Deque University
-
H36: Using Alt Attributes On Images Used As Submit Buttons - W3C
-
H36: Using Alt Attributes On Images Used As Submit Buttons
-
A Guide: The Right Way To Write Alt Text - Clique Studios
-
Image ALT Tag Tips For HTML - Accessibility At Penn State
-
Writing Alt Text For Accessibility: Guidelines And Examples
-
Just Need To Clarify, Alt Text On Buttons Is The Name Of The Button?
-
Alt Text: Why It's Important For Accessibility & SEO - Moz
-
Working With ALT Tags
-
Input-image-alt - Accessibility Insights
-
How To Write Good Alt Text | Nomensa
-
Alternative Text - IT Accessibility - NC State University