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 Svg Tag Alt Attribute
-
Accessible SVGs | CSS-Tricks
-
Accessibility: Recommended Alt-text Convention For SVG And MathML?
-
Svg-img-alt - Accessibility Insights
-
SVG & Icon Fonts | Accessibility Guidelines
-
Accessible SVG: Methods For Adding Alternative Content - Web Design
-
Is It Possible To Add An 'alt Text' To A Svg File - BigCommerce Support
-
SVG Images And Graphics Require Accessible Text Axe Rules
-
HTML Img Alt Attribute - W3Schools
-
6.2. Managing Alternative Text On SVG (Scalable Vector Graphics)
-
What Should You Use In Place Of Alt Tags For SVG Files For SEO ...
-
How To Add Alt Text To Embedded SVG? - Custom Code - Forum
-
Usage Of Alt Attribute For SVG Elements Is Not Allowed #5569 - GitHub
-
Accessible SVGs - University Of Melbourne
-
Decorative Images | Web Accessibility Initiative (WAI) - W3C