t - Web APIs | MDN

  • Skip to main content
  • Skip to search
HTMLImageElement: alt property Baseline Widely available

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 contribute

This page was last modified on Nov 7, 2025 by MDN contributors.

View this page on GitHub • Report a problem with this content Filter sidebar
  1. The HTML DOM API
  2. HTMLImageElement
  3. Constructor
    1. Image()
  4. Instance properties
    1. align Deprecated
    2. alt
    3. attributionSrc Deprecated
    4. border Deprecated
    5. complete
    6. crossOrigin
    7. currentSrc
    8. decoding
    9. fetchPriority
    10. height
    11. hspace Deprecated
    12. isMap
    13. loading
    14. longDesc Deprecated
    15. name Deprecated
    16. naturalHeight
    17. naturalWidth
    18. referrerPolicy
    19. sizes
    20. src
    21. srcset
    22. useMap
    23. vspace Deprecated
    24. width
    25. x
    26. y
  5. Instance methods
    1. decode()
  6. Inheritance
    1. HTMLElement
    2. Element
    3. Node
    4. EventTarget
  7. Related pages for HTML DOM
    1. BeforeUnloadEvent
    2. DOMStringMap
    3. ErrorEvent
    4. HTMLAnchorElement
    5. HTMLAreaElement
    6. HTMLAudioElement
    7. HTMLBRElement
    8. HTMLBaseElement
    9. HTMLBodyElement
    10. HTMLButtonElement
    11. HTMLCanvasElement
    12. HTMLDListElement
    13. HTMLDataElement
    14. HTMLDataListElement
    15. HTMLDialogElement
    16. HTMLDivElement
    17. HTMLDocument
    18. HTMLElement
    19. HTMLEmbedElement
    20. HTMLFieldSetElement
    21. HTMLFormControlsCollection
    22. HTMLFormElement
    23. HTMLFrameSetElement Deprecated
    24. HTMLGeolocationElement Experimental
    25. HTMLHRElement
    26. HTMLHeadElement
    27. HTMLHeadingElement
    28. HTMLHtmlElement
    29. HTMLIFrameElement
    30. HTMLInputElement
    31. HTMLLIElement
    32. HTMLLabelElement
    33. HTMLLegendElement
    34. HTMLLinkElement
    35. HTMLMapElement
    36. HTMLMediaElement
    37. HTMLMenuElement
    38. HTMLMetaElement
    39. HTMLMeterElement
    40. HTMLModElement
    41. HTMLOListElement
    42. HTMLObjectElement
    43. HTMLOptGroupElement
    44. HTMLOptionElement
    45. HTMLOptionsCollection
    46. HTMLOutputElement
    47. HTMLParagraphElement
    48. HTMLPictureElement
    49. HTMLPreElement
    50. HTMLProgressElement
    51. HTMLQuoteElement
    52. HTMLScriptElement
    53. HTMLSelectElement
    54. HTMLSourceElement
    55. HTMLSpanElement
    56. HTMLStyleElement
    57. HTMLTableCaptionElement
    58. HTMLTableCellElement
    59. HTMLTableColElement
    60. HTMLTableElement
    61. HTMLTableRowElement
    62. HTMLTableSectionElement
    63. HTMLTemplateElement
    64. HTMLTextAreaElement
    65. HTMLTimeElement
    66. HTMLTitleElement
    67. HTMLTrackElement
    68. HTMLUListElement
    69. HTMLUnknownElement
    70. HTMLVideoElement
    71. HashChangeEvent
    72. History
    73. ImageData
    74. Location
    75. MessageChannel
    76. MessageEvent
    77. MessagePort
    78. Navigator
    79. PageRevealEvent
    80. PageSwapEvent
    81. PageTransitionEvent
    82. Plugin Deprecated
    83. PluginArray Deprecated
    84. PromiseRejectionEvent
    85. RadioNodeList
    86. TimeRanges
    87. UserActivation
    88. ValidityState
    89. Window
    90. WorkletGlobalScope
  8. Guides
    1. Using microtasks in JavaScript with queueMicrotask()
    2. In depth: Microtasks and the JavaScript runtime environment

Từ khóa » Html Image Alt Text Color