Validation W3C HTML5 img noscript facebook.com

I am trying to check my page as HTML 5 (W3c). And I have the following error: the "img" element is not allowed here (as a child of the "noscript"). The "noscript" element, when the "head" child element should contain only the following child elements: "link", "style" and "meta".

At https://developers.facebook.com/docs/ads-for-websites/conversion-pixel-code-migration, the recommendation for my code is: "Copy and paste the updated code snippet between <head> and </head> ; in The HTML code of your site on which you want to track conversions, for example, to track your registration, put the code on your "verified registration" web page. "

see source code:

 <head> <script type="text/javascript"> var fb_param = {}; fb_param.pixel_id = '1234567890'; fb_param.value = '10.00'; fb_param.currency = 'USD'; (function(){ var fpw = document.createElement('script'); fpw.async = true; fpw.src = '//connect.facebook.net/en_US/fp.js'; var ref = document.getElementsByTagName('script')[0]; ref.parentNode.insertBefore(fpw, ref); })(); </script> <noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/offsite_event.php?id=1234567890&value=10.00&currency=USD" /></noscript> </head> 

Is it possible to change this code and pass the test (in the chapter section)?

+5
source share
2 answers

The W3Cs HTML5 specification defines the content model of the noscript element in the head element as follows:

[...] in any order, zero or more link elements, zero or more style elements and zero or more meta elements.

As you can see, it cannot contain anything but link / style / meta elements. So, no, its impossible to change anything to allow img inside the noscript element inside the head element.

But you can have img inside noscript if you put the noscript element in body , since the content model is in this case:

transparent, but there should be no noscript descendants of elements.

Transparent means that it has the same content model as its parent. For example, if noscript is inside a div , it can contain everything that a div can contain (except for another noscript ).

+3
source

Like @ Aplet123 and @unor, you can move the <noscript> element to the body. I did this on my pages, and it seems to work painlessly.

To check, I used the Facebook Pixel helper from Chrome, and it behaves exactly like the previous version of my page with the <noscript> element in my head according to the Facebook code sample.

Finally, to make sure the HTML validator is happy, you also need to add alt="Facebook pixel" or similar to the <img> element.

-1
source

Source: https://habr.com/ru/post/1243462/


All Articles