In HTML I could do:
<noscript><link href="css/stylenojs.css" rel="stylesheet" type="text/css" /></noscript>
Is there some compliant way to do so in XHTML Transitional or Strict documents?
In HTML I could do:
<noscript><link href="css/stylenojs.css" rel="stylesheet" type="text/css" /></noscript>
Is there some compliant way to do so in XHTML Transitional or Strict documents?
The example you give is invalid in HTML as well as XHTML. No current recommendation provides a way to include a stylesheet unless scripting is enabled.
In general, you should avoid
<noscript>
. Start with something that works, and then build on it.In this case, you could write your stylesheet for non-JS clients, then:
… and include additional rule-sets specific to JS being enabled with:
Alternatively, you could do something like:
and
The current chosen answer is misleading.
<noscript>
is HTML valid as well as the example provided in the question.W3C says:
Now, the little dirty secret about XHTML is that browsers are not treating XHTML in XML unless the documented is served in
application/xhtml+xml
as the MIME type.In case your page is served as proper
XHTML
, then a solution might be changing thedoctype
of the page to HTML5 and MIME type totext/html
.