question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

next/image generates invalid html tag (empty alt attribute)

See original GitHub issue

What 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.

image

Снимок экрана 2021-07-14 в 12 23 01

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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
styflecommented, Aug 4, 2021

Agreed, the issue is the role 👍

See PR #27767 for the fix, thanks!

0reactions
balazsorban44commented, Jan 28, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found