About This HTML Issue
An srcset attribute must not end with a trailing comma, as each entry must be a complete image candidate string with a URL and an optional width or pixel density descriptor.
The srcset attribute accepts a comma-separated list of image candidate strings. Each string contains a URL and, optionally, a width descriptor (like 400w) or a pixel density descriptor (like 2x). A trailing comma after the last entry creates an empty image candidate string, which is invalid.
This error often appears when srcset values are built dynamically by a template engine or CMS that appends a comma after every item, including the last one.
Invalid example
<img
srcset="image-small.jpg 400w,
image-medium.jpg 800w,
image-large.jpg 1200w,"
sizes="(max-width: 800px) 400px, 800px"
src="image-medium.jpg"
alt="A sample photo"
>
The trailing comma after image-large.jpg 1200w, produces the validation error.
Fixed example
<img
srcset="image-small.jpg 400w,
image-medium.jpg 800w,
image-large.jpg 1200w"
sizes="(max-width: 800px) 400px, 800px"
src="image-medium.jpg"
alt="A sample photo"
>
Removing the trailing comma after the last image candidate string fixes the issue.
Find issues like this automatically
Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.