1

I am loading a background image for a webpage through CSS. This allows me to load a different sized image based on viewport width, to help the page load speed on mobile/tablet.

<img id="backimage">

The only issue with this is that it creates the following W3C validation errors (the only errors I have and the client specifically wants the page to validate):

Error Line 6, Column 8: required attribute "TYPE" not specified <script>

The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.

Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.

Error Line 39, Column 24: required attribute "SRC" not specified

<img id="backimage">

The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.

Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.

1 Answer 1

1

Generate the whole element with JavaScript/DOM, then append it to its parent element.

Don't put a placeholder element which doesn't have everything the specification requires.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.