I'd like to exclude Internet Explorer from using a specific CSS class.
Is this possible?
Details:
I have a css class that looks like -
input[type="radio"]:checked, input[type="radio"]:hover
{
box-shadow: 0px 0px 10px #90BBD4;
}
Since Firefox's latest browser update removed the -moz-box-shadow property and I believe it now uses the default box-shadow instead, ... my Firefox is still working great, but Internet explorer now recognizes it and messes up the look.
How might I go about excluding IE from using this class or work around it somehow?
This will set a class of the IE version the client browser is using.
<!--[if lt IE 7 ]> <html class="ie6" lang="en" xml:lang="en"> <![endif]-->
<!--[if IE 7 ]> <html class="ie7" lang="en" xml:lang="en"> <![endif]-->
<!--[if IE 8 ]> <html class="ie8" lang="en" xml:lang="en"> <![endif]-->
<!--[if IE 9 ]> <html class="ie9" lang="en" xml:lang="en"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html class="" lang="en"> <!--<![endif]-->
Then using CSS you can target it to a specfic browser by using something like:
.ie7 #wrapper
{
display:none;
}
When people feel the need to make their website look different in different browsers (which is the complete opposite of what the Internet should be like...) they use this:
<!--[if IE]><html class="ie"><![endif]-->
<!--[if !IE]>--><html><!--<![endif]-->
Then in your CSS you can put html.ie to make IE-specific rules.
You can use IE conditional comments and set css rules in the css you include inside the comment.
For example:
<!--[if IE]><link rel="stylesheet" href="ie.css" /><![endif]-->
or:
<!--[if IE]><style>*ie style rules here*</style><![endif]-->
Related
I currently have the following html prefix namespaces
<html lang="en" dir="ltr" prefix="content: http://purl.org/rss/1.0/modules/content/
dc: http://purl.org/dc/terms/ foaf: http://xmlns.com/foaf/0.1/
og: http://ogp.me/ns# rdfs: http://www.w3.org/2000/01/rdf-schema#
schema: http://schema.org/ sioc: http://rdfs.org/sioc/ns#
sioct: http://rdfs.org/sioc/types# skos: http://www.w3.org/2004/02/skos/core#
xsd: http://www.w3.org/2001/XMLSchema# ">
I was reading something and came across this:
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
Here are my questions:
1./ Does adding this to my html web page interfere/collide with the current prefix namespace I have?
2./ For the situation when it says if (gte IE 9) why is there a closed comment <!--> before the html declaration and <!-- after the declaration
3./ What can i do with this sort of declaration?
You can only have one <html> tag, but you could add the attributes from your first example to the <html> tag in the second. What are you trying to achieve?
Your second example contains conditional comments. They are only supported by older versions of Internet Explorer. Other browsers will treat them as normal HTML comments - i.e. they will ignore them. The last line of the example closes the comment before the HTML tag so that all non IE browsers will still see the <html lang="en"> tag. If it was instead written as
<!--[if (gte IE 9)|!(IE)]><html lang="en"><![endif]-->
the <html> tag would be inside the comment and would therefore be ignored by all browsers.
The purpose of the code you posted is to output an IE-version specific class to the <html> tag. It would allow you to write CSS declarations for targetting specific IE versions, e.g.:
body {
background-color: white;
}
.ie7 body {
background-color: red;
}
This would make the page background white for everyone except users of IE7, for whom it would be red.
In practice these sorts of solutions aren't used as commonly these days, unless you have a pressing need to support IE versions that Microsoft themselves no longer support.
I have a page, where I need to show help text based on the version of the IE. I have decided to use conditional comments as per this blog. My html page looks like this ...
<!DOCTYPE html>
<html>
<head>
<title>Application Title</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
</head>
<!--[if lt IE 9 ]><body style="margin: 0px;" class="ie9lt"><![endif]-->
<!--[if IE]> <body style="margin: 0px;" class="ie9"> <![endif]-->
<!--[if (gt IE 10)|!(IE)]>-->
<body style="margin: 0px;"><!--<![endif]-->
<div id="id1">
....
....
</html>
I have opened this file on IE 9 but checked the html by inspect the elements option but my body element didn't have ie9 class (for that matter no class) associated with it. Am I missing something here? Please help
I've checked your HTML with IE9 and it works perfectly fine. I can see that body has ie9 class.
Can you see the same in HTML inspector as below? Also, is your browser mode set to IE9?
Sometimes, when you have errors in your HTML document IE automatically switches to Compatibility View mode and then your body class is ie9lt (and not ie9).
you can try to be more specific en work on the root HTML tag:
<!doctype html>
<!--[if IE 7 ]><html lang="en" class="ie7"><![endif]-->
<!--[if IE 8 ]><html lang="en" class="ie8"><![endif]-->
<!--[if IE 9 ]><html lang="en" class="ie9"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html lang="en">
<!--<![endif]-->
I'd only put style definitions in those comments, nothing else. Let the html document stay as clean as possible. That's probably one of the most messy implementations of that hack there is.
I have a simple div with a 2px thick border and absolute positioning thats hidden until its parent element is hovered over. Due to IEs box model, the position of said div is somewhat off in IE, but not any other browser. I don't want to add an entirely seperate style sheet for IE, I just want to modify the class itself if the browsing person is using IE.
So how does one modify or add a specific class for IE only?
You need to use something called conditional comments. These only work in IE (other browsers will see them as comments) so they are a great way to target IE only.
Example - if you want something to be done in IE6 use the following:
<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]--
To find out more, visit the official MSDN source regarding conditional comments.
You can just add following conditional snippets at your html (or whatever) file. After that you can define new class attributes in your ie_stylesheet.css
<!--[if IE]>
<link type="text/css" rel="stylesheet" media="all" href="ie_stylesheet.css"/>
<![endif]-->
I think there are enough explanations here.
You can try and avoid the IE stylesheet by adding a CSS reset to the beginning of your stylesheet. Please take a look at the following: http://www.cssreset.com/scripts/html5-doctor-css-reset-stylesheet/
The reset should help making elements behave the same in all browsers.
I've found this usage of conditional comments to be a pretty elegant way of tagging your <html> tag with classes that you can work with in your CSS and JS:
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
As a contrived example, if you want to target IE6 to make all links red, you would use specificity like this:
.lt-ie7 a {
color: red;
}
No need for a separate style sheet.
Source: Conditional stylesheets vs CSS hacks? Answer: Neither!
i seen lot of website have specific code for ie6, ie7,ie8.
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
and i seem html have specific class like this
<html class=" js no-flexbox flexbox-legacy canvas canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths">
any one just tell what is the use this codes
This is instruction for Moderniz. If JavaScript in your browser is enabled, Modernizr changes no-js to js class, so you can define CSS styles for JavaScript-enabled browsers and for JavaScript-disabled browsers
It's put there so that if there IS Javascript support, then you can use JS to remove the no-js class.
You use the no-js class to style CSS for your webpage if you normally require JS for your site to function properly.
This provides a degraded but functional format, if you want to serve enough HTML and enough forms to make the page work without JS, but then hide the ghetto-version and replace it with the shiny and fancy stuff, later.
<!--[if IE]><![endif]--> is Microsoft's conditional comment.
So for IE version < 7 ([if lt IE 7]), <html lang="en" class="no-js ie6"> is used;
For IE version 7 ([if IE 7]), <html lang="en" class="no-js ie7"> is used;
and so on.
Finally, for IE version > 9([if gt IE 9]), <html lang="en" class="no-js"> is used.
And since it is a Microsoft specific comment, all non-IE browsers will treat it as normal comment, so only <html lang="en" class="no-js"> (the only un-commented part) is used.
Can anyone tell me what this is:
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie ie6" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie ie7" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie ie8" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js iframe" lang="en"> <!--<![endif]-->
I have seen this on so many pages but there is no JavaScript link on some of the pages to support the document declaration.
It seems to be snippet from html5 Boilerplate's standard format for 'browser detection' , see http://html5boilerplate.com/
The section that you have highlighted allows for only one section of the <html> tag to be parsed depending upon the flavour of browser that the site visitor is using.
Read more about this method at the authors website > http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
This is the doctype for HTML5 pages
<!DOCTYPE html>
The following lines means that the code between the commented tags is IE specific (first one is for browsers less than IE7 (IE6, IE5, etc...), second one for IE7, third one for IE8 and the last one for >= IE9)
<!--[if lt IE 7]> <html class="no-js ie ie6" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie ie7" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie ie8" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js iframe" lang="en"> <!--<![endif]-->
<!--[if lt IE 7]>
That means that code inside the <!--[if lt IE 7]>...<![endif]--> will work only in IE 7 browser
and <!--[if lt IE 8]>...<![endif]--> only in IE8 browsers
This hint working only in IE browsers. For example you can write <!--[if lt IE 7]><style .../><![endif]--> and this style will work only in IE 7. Than on the next line you can write <!--[if lt IE 8]><style .../><![endif]--> and this styles will work only in IE8
Those are only checks for compatibility with older browsers
<!DOCTYPE html> usually refers to HTML5, browsers below IE9 don't support HTML5 at all, so tweaks are needed. That's why there are HTML if-clauses that check if you use IE and which version. The HTML element gets a special class for that browser version so that CSS can see if it's IE and in which version (e.g. for fixing the box model of IE6)
The no-js class probably gets removed by JavaScript so that CSS can access specific elements only if JavaScript is on/off
You should use this as your Doctype: <!DOCTYPE html>
The rest is not relevant for the doctype, and is IE-specific.