In this post, we will learn how to create stylesheet only for IE (Internet Explorer). When we target only IE browser then some CSS property does not work. For this we need to create a specific stylesheet for IE browser. So how we can do this, we will learn in this post. 


How To Create Stylesheet Only For Internet Explorer (IE) ?


Create Stylesheet Only For Internet Explorer

To create stylesheet only for Internet Explorer we use this following code:


This code works for all versions of IE.


<!--[if IE]>

<link rel="stylesheet" href="ie-stylesheet.css">

<![endif]--> code-box


We use this above code in our HTML as following:


<!DOCTYPE html>

<html>

<head>

<title>How To Create Stylesheet Only For Internet Explorer(IE) ?</title>

<link rel="stylesheet" href="style.css">

<!--[if IE]>

<link rel="stylesheet" href="ie-stylesheet.css">

<![endif]-->

</head>

<body>

<h1>CodexRadar</h1>

<p>How To Create Stylesheet Only For Internet Explorer(IE) ?</p>

</body>

</html> code-box


If we want to target all browsers except IE. Then we write this code as following:


<!--[if !IE]>

<link rel="stylesheet" href="ie-stylesheet.css">

<![endif]--> code-box


If we want to target a specific version of IE. In this example below we write code for IE9 version:


<!--[if IE 9]>

<link rel="stylesheet" href="ie-stylesheet.css">

<![endif]--> code-box


If we want to target IE9 and higher versions of IE. Then we write this code as following:


<!--[if gte IE 9]>

<link rel="stylesheet" href="ie-stylesheet.css">

<![endif]--> code-box


In this example above gte means greater than or equal to.


So with the help of these codes we can easily create stylesheet only for Internet Explorer browser.



Summary

In this post we learned how to create stylesheet only for Internet Explorer. You try to make it yourself. I hope you make. If you face any problem, then comment and tell us. Keep visiting the blog to read more similar posts.

Post a Comment

Previous Post Next Post