Jump to content

Why....


Aureole

Recommended Posts

Why is it unvalid to do something like this in the <head>

 

<noscript>
<style type="text/css">
div.sub_menu_item, div#nav_2, a.sub_menu_item_a, a#nav_more{display:none;}
div.parent_menu_item{background:#242424;color:#FFFFFF;font-size:0.91em;font-weight:bold;width:189px;padding:4px 4px 4px 4px;border-bottom:1px solid #000000;cursor:default;}
</style>
</noscript>

 

I just want to hide things from people who don't have Javascript... but they only let you put <noscript> in the <body>... If you ask me this is stupid. Is there no way around this?

Link to comment
Share on other sites

unvalid? - w3c CSS Validation or w3c JavaScript Validation or .........?

 

because you can use CSS in a noscript tag in the head of your page; whether it is w3c valid or not and why - you'd have to ask them.

 

 

<script language="javascript">
alert("JavaScript Enabled");
</script>
<noscript>
<style type="text/css">
body {background:red}
</style>
</noscript>
</head><body>

 

Link to comment
Share on other sites

HTML Validation.

 

Line 7, Column 9: document type does not allow element "NOSCRIPT" here.

 

<noscript>

 

The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

 

One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).

 

...and I know I can still do it but it invalidates my page... and it's nice to try and keep everything valid, no?

Link to comment
Share on other sites

It's good to try to validate the best you can, but there are some many non 100% w3c validated pages out there. I would venture to say that if you try to validate most web pages out there; that your going to get some type of invalid error in some category; whether it be HTML, XHTML, CSS, JavaScript, XML, or whatever. Take Yahoo for example; run it through HTML validation checker and I guarantee your going to get some errors - I just tested it and I did.

Link to comment
Share on other sites

Maybe your right. I'll just change the "Valid HTML and CSS" to "<em>Almost</em> Valid HTML and CSS". I have one error on every page and that's it, the error being a result of HTML being dumb and not letting me serve different CSS to people with/without Javascript.

 

At least I got everything else to validate I guess. Thanks anyhow...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.