Getting CNZZ Analytics to Pass W3C Validation
Translated from Chinese by Claude. Read the original
Just a quick note~ I was tinkering with my wordpress again, because the CNZZ analytics code isn’t standards-compliant~ so I had to modify it~ to get CNZZ to pass W3C validation.
Here’s the original code
1 | <script src="http://s94.cnzz.com/stat.php?id=1979318&web_id=1979318" language="JavaScript"></script> |
Then I changed it to the following
1 | <script type="text/javascript" src='http://s94.cnzz.com/stat.php?id=1979318&web_id=1979318' language='JavaScript' charset='gb2312'></script> |
Most analytics code has the following problems:
1.Every & in URLs and text has to be replaced with &
2.All attributes and tag names must be lowercase, and you need to specify the “type”, note the double quotes
3.Image img tags must have an alt attribute
4.Line breaks must use <br />
After carefully fixing these, it will pass validation