Forum Moderators: open

Message Too Old, No Replies

<noscript> block does not validate in W3C Validator

noscript validation problems

         

indiechild

2:30 pm on Nov 26, 2002 (gmt 0)

10+ Year Member



Hi everyone,

for some reason I can't get a <noscript> block to validate in my pages... I didn't have this problem before (a few days ago), but with the "new-look" W3C Validator I get this bizarre error:

[validator.w3.org...]

Line 103, column 9: document type does not allow element "noscript" here; missing one of  
"object", "applet", "map", "iframe", "button", "ins", "del" start-tag

I've checked and re-checked but my tired eyes can't find anything wrong with the HTML...

I've also created a test.html page which has nothing but the <noscript></noscript> tags and this fails to validate also.
[validator.w3.org...]

can anyone tell me what I'm missing here? (sorry about the bad source formatting -- I'm using phpCMS and unfortunately it strips all the indenting from your source HTML)

ta, cheers

Sinner_G

2:48 pm on Nov 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can't tell what the error is, but it (probably) is not the <noscript> tag. I have a page with noscript tag (including an anchor tag same as yours) which validates without problems.

moonbiter

3:21 pm on Nov 26, 2002 (gmt 0)

10+ Year Member



A
noscript
element, cannot be contained within a paragraph (
p
) element. A list of valid elements it can be contained in can be found here [htmlhelp.com].

indiechild

3:32 pm on Nov 26, 2002 (gmt 0)

10+ Year Member



ahh I see... it was so darn simple but I could never understand those cryptic W3C Validator error messages ;)

I suspect the W3C Validator might've been buggy, because I've had the same HTML code for several weeks and it never raised a complaint before.

thanks moonbiter :)

actually I've got another question... if I can't use <noscript> inside the <p> tags, that's really annoying, because I'd like all my content to be properly formatted in paragraph tags (which is also semantically correct)... and I'm using an anti-spam mailto javascript that generates the <noscript> tags, hence my dilemma. Is there anything similar to <p> that I can use the <noscript> tags in while still creating valid and semantically correct HTML code?

I'm currently using <blockquote> in place of the <p> tag, but that is a hack workaround and not semantically correct :(

and also: why did the W3C make it illegal to use <noscript> inside <p> tags? It just doesn't make any sense to me... :(
ah bugger it...

moonbiter

3:59 pm on Nov 26, 2002 (gmt 0)

10+ Year Member



Is there anything similar to <p> that I can use the <noscript> tags in while still creating valid and semantically correct HTML code?

Well,

div
is a generic container element that you could use for this. But I don't see why you don't do something like:

<p>Blah blah blah</p>
<p><script type="text/javascript">function whatever()</script></p>
<noscript><p>Your noscript content</p></noscript>

My suspicion is that the script could be modified in some way to allow you to do what you want. Or do you not have the option modifying the anti-spam javascript?

why did the W3C make it illegal to use <noscript> inside <p> tags? It just doesn't make any sense to me

That, I would agree with. It seems insane that they would allow the

script
element inside a paragraph (they do [htmlhelp.com]) but not the
noscript
element.

indiechild

4:15 pm on Nov 26, 2002 (gmt 0)

10+ Year Member



Thanks again moonbiter, I'm now using <div> instead which can safely contain the <noscript> block with no validation errors :)

you're right about the javascript rewriting, but it's not practical in this case because I'm planning to use the (PHP-generated) anti-spam mailto Javascript in a variety of contexts, most of them inline within sentences, so it would be irksome to have to include an entire sentence block anew every time I used the script :)