1. Using The
Most people use the noscript tag, and it works like a charm in most cases. But there are many discussions going all over the web to stop using it. Some of them are here and here.
With HTML5, you can even add the noscript tag to the head of the document, prior to that, it was limited only to the body tag. This gives it another edge over all other methods, since you can now declare styles even before the content of the page has loaded
2. Using JavaScript To Add A Class
This method works well for the most part, but the problem comes when you will want to style the content for the browsers that don't support JavaScript. Since JavaScript will add a new class, you have no way to know if it will be added or not.
3. Using JavaScript To Replace A Class
This method is an extension of the second method, and likely to be the best one. To have a solution for the problem in method two, we give a class to an element first, and then replace that class with another class. This way, you can style the elements using the former class for the browsers that don't support JavaScript, and use the latter class, for the browsers with JavaScript support.
Implementation
- Add a class, say, 'no-js' to the tag. You can style all your elements with this class. This class will only be available on browsers with no JavaScript support.
Add this code in your JavaScript file, or inside the
Would love to here from you...