next/image generates invalid html tag (empty alt attribute)
See original GitHub issueWhat version of Next.js are you using?
11.0.1
What version of Node.js are you using?
15.7.0
What browser are you using?
safari
What operating system are you using?
macOS
How are you deploying your application?
other
Describe the Bug
As I see, next/image
generates some divs with image inside it. I don’t know the exact reason for that, but this additional image has empty alt
attribute which prevent site from being passed html validator.
Expected Behavior
To pass validation
To Reproduce
import Image from 'next/image';
<Image
{...rest}
src={(imgSrc as StaticImageData) || fallback}
alt={alt}
unoptimized
className={className}
onError={() => {
setImgSrc(fallback);
}}
/>
`
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Next.js: empty alt tag when using Image Component
It is currently a 1x1 GIF, but scripts will change its source to load it (when user is about to view it, i.e....
Read more >Image Empty Alternative Text - Equalize Digital
No images should have a missing alt attribute. Empty alt tags and accessibility. Generally, if the alternative text is empty, screen readers will...
Read more >next/image - Next.js
The alt property is used to describe the image for screen readers and search engines. It is also the fallback text if images...
Read more >Allow empty alt attribute in markdown editor images · Issue #828
To clarify, it's invalid html to have no alt attribute at all, but blank alt attributes (i.e. alt="" ) are actually the recommended...
Read more >Next.js automatic image optimization with next/image
Ordinarily, the sourced image, image.jpg , is embedded into a web page, assuming the image is in the same directory as the HTML...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Agreed, the issue is the role 👍
See PR #27767 for the fix, thanks!
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.