Make WordPress Core

#62233 closed defect (bug) (reported-upstream)

New img sizes=auto attribute appears to break HTML validation at w3.org

Reported by: oldrup Owned by: joemcgill
Priority: normal Milestone:
Component: General Version:
Severity: minor Keywords:
Cc: Focuses: performance

Description

The new sises="auto,..." attribute added to image tag, does trigger an error in the HTML validator at w3.org

Sample error:

Bad value auto, (max-width: 384px) 100vw, 384px for attribute sizes on element img: Bad CSS number token: Expected a minus sign or a digit but saw a instead at auto,.

<img width="384" height="124" src="https://oldrup.net/wp-content/uploads/2024/07/relevanssi-banner-3… 1544w" sizes="auto, (max-width: 384px) 100vw, 384px" itemprop="image" style="aspect-ratio: 3/1;" />

related to https://core.trac.wordpress.org/changeset/59008

That might be a shortcoming of the validator not recognizing the rather new attribute, but just so you are aware, that sites that would validate fine under WP 6.6, appears to fail under WP 6.7 beta 3.

Change History (2)

#1 @joemcgill
22 months ago

  • Focuses performance added
  • Milestone Awaiting Review6.7
  • Owner set to joemcgill
  • Status newreviewing

Thanks for the report, @oldrup. As you mention, sizes="auto" is a relatively new addition to the HTML spec, and already has pretty good browser support, so I suspect that this is a bug with the validator that will need to be updated, but we should look into it to be sure.

#2 @joemcgill
22 months ago

  • Milestone 6.7
  • Resolutionreported-upstream
  • Status reviewingclosed

Indeed, this looks like a bug that has already been reported upstream.

Note: See TracTickets for help on using tickets.