Hi, I'm using a small snippet of JS to add a presentational element to my blockquotes (As seen here):
<script type="text/javascript">
$('blockquote.message').append('<span class="arrow" />');
</script>
But the W3C validator hates that crap:
document type does not allow element "span" here
What am I doing wrong? Is there a way to correct this error, while maintaining the function?
Thanks!
From stackoverflow
-
The blockquote tag can only contain block elements such as P, H1..n, OL/UL, PRE, DL, DIV, NOSCRIPT, BLOCKQUOTE, FORM, HR, TABLE, FIELDSET, ADDRESS
RichieHindle : The W3C validator doesn't run the JavaScript, so it doesn't know he's adding a span to a blockquote. It's seeing the " and tags. That's why you need CDATA. -
I assume you're using XHTML? You need wrap your JavaScript in CDATA:
<script type="text/javascript"> //<![CDATA[ $('blockquote.message').append('<span class="arrow" />'); //]]> </script>See the XHTML reference here: http://xhtml.com/en/xhtml/reference/script/ - "If the script element contains embedded script and that script contains XHTML markup characters such as <, >, & and ", then the script should be enclosed in CDATA"
John Stephens : Thanks! I saw your comment on the other answer too. Does adding a span to a blockquote by javascript matter? I could also us a self-closing div if that would be better.RichieHindle : I honestly don't know. It's against the spec, but the browsers will almost certainly just cope. If you want to be sure, use a div.
0 comments:
Post a Comment