/    Sign up×
Community /Pin to ProfileBookmark

<noscript> problem in validator

This following HTML code :

[code=html]
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN”
“http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<link rel=”stylesheet” type=”text/css” href=”stylesheet.css” />
<title>Testing</title>
</head>
<body>
<p>
<script type=”text/javascript”>
<!–
document.write(“Hello World!”)
//–>
</script>
<noscript>Your browser does not support JavaScript!</noscript></p>
</body>
</html>
[/code]

has 2 errors on validator output, using validator with XHTML 1.1 doctype.
Line 14, Column 10: character data is not allowed here .
<noscript>Your browser does not support JavaScript!</noscript></p>
and
Line 14, Column 61: end tag for “noscript” which is not finished .
&#8230;ript>Your browser does not support JavaScript!</noscript></p>

I think :
1. the <noscript> has wrapped in a container element, <noscript> has no
attribut, <noscript> is not using XHTML-style self-closing tags. So why the
first error is occured?
2. i have closed the <noscript> tag properly. I also have closed the <p> tag
properly. So why the second error is occured??

Do the code invalid or the validator’s bug?
Thank you for giving me more and more reference on this problem.

Andre

to post a comment
HTML

5 Comments(s)

Copy linkTweet thisAlerts:
@felgallApr 25.2008 — Why are you using <noscript> at all since hiding the paragraph from the JavaScript is just as easy and does away with non-semantic tags in the HTML and allows you to be more selective than just does/doesn't support SavaScript as you can also check whether the required JavaScript features are supported.

The only place where a <noscript. tag would actually be useful is around a stylesheet that styles the page differently depending on whether JavaScript is enabled or not (which would do away with the short delay until the JavaScript runs to hide all the no script elements) but since styles must go in the head and noscript can only go int the body the noscript tag is basically useless.
Copy linkTweet thisAlerts:
@andre4s_yauthorApr 28.2008 — Sorry for long respond...

@Fang :

Thank you for giving me some references. Now i am fully understand how to write code using <noscript> tag in xhtml 1.1.

Here is the valid code :
[code=html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<title>Testing</title>
</head>
<body>

<noscript>
<!--No text here-->
<p>some hidden text</p>
<!--No text here-->
</noscript>

</body>
</html>
[/code]


@felgall

I am sorry.. i do not fully understand what is your point.. Maybe you can give me example.. or link maybe... Thanks for your respond..
Copy linkTweet thisAlerts:
@felgallApr 28.2008 — The following code achieves the same result but without any need for the noscript tag (and is far more flecible since you can test if specific JavaScript commands are supported rather than just whether or not javaScript itself is enabled).

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;link rel="stylesheet" type="text/css" href="stylesheet.css" /&gt;
&lt;title&gt;Testing&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p id="noscript"&gt;some hidden text&lt;/p&gt;
&lt;script type="text/javascript"&gt;document.getElementById('noscript').display = 'none';&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@andre4s_yauthorApr 29.2008 — YES.. yes...!!!

Thank you so much felgall... Now i am fully understanding your point...

New way of doing something...

Thank you again...

[RESOLVED]
×

Success!

Help @andre4s_y spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...