My HTML is almost HTML5-pliant according to the W3C Validator, only one error is remaining: the Javascript code to configure the Google Plus buttons.
Whether I add CDATA or not, the error "The text content of element script
was not in the required format: Expected space, tab, newline, or slash but found {
instead." is displayed for this line:
<script src=".js" type="text/javascript">
{"lang":"en","parsetags":"explicit"}
</script>
My HTML is almost HTML5-pliant according to the W3C Validator, only one error is remaining: the Javascript code to configure the Google Plus buttons.
Whether I add CDATA or not, the error "The text content of element script
was not in the required format: Expected space, tab, newline, or slash but found {
instead." is displayed for this line:
<script src="http://apis.google./js/plusone.js" type="text/javascript">
{"lang":"en","parsetags":"explicit"}
</script>
Share
Improve this question
edited Feb 20, 2018 at 23:52
unor
96.9k28 gold badges224 silver badges380 bronze badges
asked Jan 18, 2013 at 22:27
richeyrichey
3,9589 gold badges39 silver badges51 bronze badges
1
- Looks like your trying to pass an undefined object. – Christopher Marshall Commented Jan 18, 2013 at 22:30
2 Answers
Reset to default 3The error message is correct. A script
tag that has its src
attribute set can only contain documentation: whitespace and ments (/* ... */
or //...
).
If you just want to avoid the error, you could try creating the script
tag with js, as in the asynchronous load example. This doesn't make it valid but at least the initially served html will be without errors and validators won't plain.
...I sorely doubt you're going to win the validation-war, here.
If you've got a client/boss that is obsessed over validating (rather than being solid code -- because you can totally have flimsy, flaky, valid code), then you can tell them to drop g+, pletely.
But Google is using that script tag to load its file, that file is finding the last script tag that loaded, and then using the inner-text for configuration of the program.
Is it pletely valid syntax? Not really, no.
Perhaps they might consider trying to work within JS-ments, but really, Google will change this stuff frequently, as they take over the world and evolve web-programming (angular.js is craaazy).
While they aren't perfect, I'd suspect that their code is more solid than just "W3C validator-approved" code.