UMD Web Utilities Library
    Preparing search index...

    Function imageHasAlt

    • Checks if an image element has alt text

      Validates that an HTMLImageElement has a non-empty alt attribute. Logs an error to console if alt text is missing.

      Parameters

      • image: HTMLImageElement | null

        The image element to validate

      Returns boolean

      True if image has alt text, false otherwise. Returns true if image is null/undefined.

      const img = document.querySelector('img');
      if (!imageHasAlt(img)) {
      // Handle missing alt text
      }