HTML5 validation fail with lazy load
See original GitHub issueThe lazy load feature uses the data-lazy attribute of the IMG tag. Unfortunately, this means that the src attribute is missing, which causes HTML5 validation to fail.
Error message from W3C validator:
Element img is missing required attribute src.
Reference paragraph from HTML5 spec:
The src attribute must be present, and must contain a valid non-empty URL potentially surrounded by spaces referencing a non-interactive, optionally animated, image resource that is neither paged nor scripted.
A possible solution, is to use a src attribute with a place-holder image (low res thumb, animated loader, small icon, etc). For example, another script which support lazy loading, uses the following IMG tag format:
<img src="icon.png" data-src="image250x.jpg" data-src-retina="image500x-retina.jpg">
Issue Analytics
- State:
- Created 9 years ago
- Reactions:11
- Comments:7
Top Results From Across the Web
Lazy loading (data-src2) Jssor Slider doesn't validate against ...
To make an image lazy loading, the src attribute shouldn't be specified. The html5 validation will raise an error for image with no...
Read more >Lazy loading & HTML Validation - WordPress.org
Hi,. When i try to validate html I get this error. Should I Ignore. Error: Element style not allowed as child of element...
Read more >951697 - Error message of HTML5 input validation is not ...
Issue 951697: Error message of HTML5 input validation is not shown when using confirm ... The error message does not show in the...
Read more >Extend HTML5 Form Validation With Custom Rules And Errors
Validate form fields on submit, blur and data change. Custom validation rules. Easy to add your own validators. Custom error messages. Useful ...
Read more >Tips for authoring fast-loading HTML pages - MDN Web Docs
All eagerly loaded images are rendered before the document's load event is sent. Switching to lazy loading of images tells the browser to...
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 FreeTop 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
Top GitHub Comments
I did not solve the problem, I only offered a possible solution. If we try to use the src attribute, then it breaks the lazy load engine. I also tried using a small place-holder image and it completely broke the slider height.
Why is HTML5 validation not relevant? I believe it is more relevant than before, even google gives higher marks in their search engine to sites with valid HTML5 code, over others.
This is not a bug, and you’ve solved your own problem 😄 HTML Validation is not relevant today 😕