Reputation: 281
Look at the source code of bartzmall.pk from different browsers and you will see different classes added to the html tag for each browser.
From firefox
<html class="firefox firefox53 otherClasses">
From chrome
<html class="webkit chrome chrome58 otherClasses">
From IE
<html class="ie ie11 otherClasses">
And from opera
<html class="webkit opera opera45 otherClasses">
The class "otherClasses" refer to about 14 other classes that are common for all browsers.
How is this website able to change its source code when visited from different browsers? What purpose do these special classes that vary by browser serve?
P.S As a side question, what is the sense/wisdom/reason behind adding so many classes to the html tag?
Upvotes: 3
Views: 727
Reputation: 67778
There's a JS plugin named "modrnizer" (google it) which detects your browser type and capabilities and inserts according classes into your HTML tags, so you can setup CSS rules that respond to the particular differences between browsers using those classes .
The modrnizer website itself seems to be broken at the moment, but here is an article that describes how it works: http://html5doctor.com/using-modernizr-to-detect-html5-features-and-provide-fallbacks/
Upvotes: 6