I was reading up on some JavaScript to try and create my own slider and I came across something that confused me a little. There was a CSS rule that was as follows:
html.js #slideshow .slides img
{
position: absolute;
}
The explanation said that the rule would only be applied if JavaScript was available. Now I’m a bit confused… Would this rule be applied if JavaScript is available in the browser? Or if the file “html.js” had been included in the html page, or if any JavaScript files were included?
Thanks in advance.
The page you saw is probably using Modernizr. It is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser and works by adding a class “no-js” to the HTML element and when the page loads Modernizr replace it with set of rules that you’re testing.
Check Modernizr website for more details if you want to test specific feature in a browser.
Of ir you don’t want to use Modernizr you can do it with JavaScript by placing this directly within your
<title>tag :