- From: Raphaël Quinet <Raphael.Quinet@eed.ericsson.se>
- Date: Mon, 3 Mar 2003 16:55:22 +0100
- To: www-html-editor@w3.org
There is a problem with all versions of HTML and XHTML: the DTD allows <script> in <head> and <body>, while <noscript> is only allowed in <body> but not in <head>. The current draft of the XHTML 2.0 specification contains an example in section 15.2.3 (XHTML Scripting Module) showing how one can use nested <script> elements in <head> in order to support multiple scripting languages. However, this does not provide any fallback solution if no scripting language is supported or enabled. Allowing <noscript> in <head> would be useful if one has an external script that dynamically generates the <title>, some <meta> tags or a <link> to a stylesheet depending on some parameters. If the script cannot be loaded, a <noscript> section could at least provide some reasonable defaults. So the following example would be useful, although it is not valid (X)HTML: ... <head> <script type="text/javascript" src="/generate-head.js"> <noscript> <title>Default title</title> <link rel="stylesheet" type="text/css" href="/default.css" /> <link rel="index" href="/index.html" /> <meta name="Author">Default Author</meta> </noscript> </script> </head> ... This code seems to work in all browsers that I could test, but this is forbidden by the DTDs (HTML 4 and XHTML 1). In fact, I discovered this problem in the DTDs by trying to validate a set of pages containing some code similar to the one above and getting a number of errors related to the <noscript> element. Providing defaults without using <noscript> is not easy. For the stylesheet, this requires inserting an unconditional <link> to a default stylesheet at the beginning of the <head> section and overrriding all of its settings with a second styleheet that could be requested via the script. This is more complex and this increases the number of requests to the server. For <title>, <meta> and other <link> elements, it is necessary to call the script twice: once at the beginning of <head> before the default values and once at the end, because some browsers will only display the first <title> found while others will only display the last one. I don't know how to solve this problem in the DTD. In fact, I don't know if this is even possible, because the valid contents of <noscript> would be different if the element is used inside <head> or inside <body>. I don't think that the DTD syntax allows this, although I could be wrong. If this cannot be done in the DTD, then I would suggest adding a paragraph in the description of the <noscript> tag saying that browsers should be tolerant and accept <noscript> inside <head>. Best regards, -Raphaël P.S.: I am not subscribed to this list. It would be nice if you could CC me on any replies. I will check the mailing list archives from time to time.
Received on Monday, 3 March 2003 10:57:00 UTC