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 » Html5 Alternative Text
-
HTML Img Alt Attribute - W3Schools
-
HTML Area Alt Attribute - W3Schools
-
HTML5: Techniques For Providing Useful Text Alternatives - W3C
-
Image ALT Tag Tips For HTML - Accessibility At Penn State
-
Alt Attribute - Wikipedia
-
HTML5: Techniques For Providing Useful Text Alternatives
-
Alt Text: Why It's Important For Accessibility & SEO - Moz
-
Alternative Text - WebAIM
-
: The Image Embed Element - HTML - MDN Web Docs - Mozilla
-
Examination Of Alt Text Guidance In The HTML5 Draft
-
Requiring The Alt Attribute In HTML5 - Juicy Studio
-
HTML | Alt Attribute - GeeksforGeeks
-
What Is The Use Of Alternative Text In Image Mapping In HTML
-
HTML5 Video Element — Alternative Text - Stack Overflow