CSS if question about posing a question

What is the syntax if I want to upload a css file to my website using an if statement.

The situation is as follows:

If ie6 I load ie6_style.css

and if ie7, mozilla or new browsers, I will load style.css

+3
source share
2 answers
<link rel="stylesheet" type="text/css" href="style.css">
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="ie6_style.css">
<![endif]-->
+9
source

You will need to determine which browser is with javascript and then load the CSS.

Something like that

<script language="JavaScript"><!--
browser_version= parseInt(navigator.appVersion);
browser_type = navigator.appName;

if (browser_type == "Microsoft Internet Explorer" && (browser_version >= 7)) {
document.write("<link REL='stylesheet' HREF='012899-ie7.css' TYPE='text/css'>");
}

else if (browser_type == "Netscape" && (browser_version >= 5)) {
document.write("<link REL='stylesheet' HREF='012899-netscape5.css' TYPE='text/css'>");
}

// --></script>
0
source

Source: https://habr.com/ru/post/1727237/


All Articles