2

I've been doing a lot of searching and haven't quite found the solution to my problem.

What I'm trying to do, is have two CSS style sheets for a website. One style sheet for when javascript or jQuery is enabled, and one for when it is disabled. How would I go about doing this?

2 Answers 2

9

Use something like this:

<noscript>
<link type="text/css" href="noscript.css" rel="stylesheet" />
</noscript>

Hope this helps!

EDIT

For when JS is enabled, just create the <link> tag using JS. (document.write(...);)

Sign up to request clarification or add additional context in comments.

1 Comment

I'd advise against document.write() since this will unnecessarily delay styling while the script then styles are loaded resulting in a much longer delay for the user.
3

Your second stylesheet can just override whatever is in the first. Past (after) that, just include the second inside a <noscript> tag, like this:

<noscript>
  <link rel="stylesheet" type="text/css" href="myStyles.css">
</noscript>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.