2

I am trying to validate my document as XHTML 1.0 Transitional (W3C).

I have the following error: "document type does not allow element "noscript" here; assuming missing "object" start-tag" which corresponds to this code:

<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt=""
src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/1096/?
value=1.00&amp;label=Y-skCMY_QM&amp;guid=ON&amp;script=0"/>
</div>
</noscript>
</head>

But I get this validation failing. What is the problem? Please help me to solve this.

unor
  • 92,415
  • 26
  • 211
  • 360
Igor
  • 211
  • 3
  • 10
  • 1
    The XHTML definition doesn't include `noscript`. Your choices are to ignore the W3C error, use another doctype or use another way to detect javascript. – Mr Lister Jan 30 '15 at 17:50

1 Answers1

3

One of your solutions could be to place it in the body instead of the head of your document as following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title</title>
<meta name="viewport" content="width=device-width"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt=""
src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/1096/?
value=1.00&amp;label=Y-skCMY_QM&amp;guid=ON&amp;script=0"/>
</div>
</noscript>
</body>
</html>

This results in:

This document was successfully checked as XHTML 1.0 Transitional!

Additionally, according to this answer, it seams that it doesn’t really make difference (I'm talking about head vs body here):

Have done the move with the Google Ad section outside of HEAD and just in the BODY part itself. Really doesn't make a difference since when it was moved, it was just right after the parameters used for the ads to display.

Solution #2 In case You will need to get rid of the <noscript> at all, You can try to make the following:

<div id='noscript' style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt=""
src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/1096/?
value=1.00&amp;label=Y-skCMY_QM&amp;guid=ON&amp;script=0"/>
</div>
<script>document.getElementById('noscript').style.display='none'</script>

This makes things work absolutely the same as in the first solution. If JavaScript is disabled, <script>...</script> won't be executed, thus <div>...</div> would be shown.

Community
  • 1
  • 1
Dmytro Dzyubak
  • 1,562
  • 2
  • 22
  • 35