I coded a website, and obviously when uploaded it to test it, its messing up in IE.
Im trying to insert an IE only stylesheet, but its not working, the code I have is:
<!--[if IE]> <link rel="stylesheet" type="text/css" href="ieonly.css" />
<![endif]-->
Whats going wrong?
Any one can help me, that would be amazing?
On IE everything is getting mis aligned.
Well your syntax seems ok.Try using the developer toolbar to check if the path to your CSS file is right
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="all-ie-only.css" />
<![endif]-->
Related
Is there a way to load a different CSS file for a specific browser?
like (poor pseudo code):
if firefox
<link rel="stylesheet" type="text/css" href="includes/MyCssFirefox.css" />
if chrome
<link rel="stylesheet" type="text/css" href="includes/MyCssChrome.css" />
if Safari
<link rel="stylesheet" type="text/css" href="includes/MyCssSafari.css" />
Ideal solution you want does not exist:
Unfortunately, a cross browser solution does not exist IF you are trying to do it on the HTML itself. However, it will work for most versions of IE. Like such:
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="includes/myIEGeneralStyle.css" />
<![endif]-->
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="includes/myIE6Style.css" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="includes/myIE7Style.css" />
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="includes/myIE8Style.css" />
<![endif]-->
So the best solution:
How about a Javascript solution like such: Browser Detection. Read a bit about this class to better clarify, what that file is basically doing is simply the concept like such:
var browser = navigator.userAgent.toLowerCase().indexOf('chrome') > -1 ? 'chrome' : 'other';
Obviously, it does more than just detect type of browser. In fact, it knows the version, OS, and much more detail that you can read about in that link. But, it does go and check all the types of browsers by replacing 'chrome' with 'mozilla', 'explorer' and so on...
Then to add your css files, just follow up with conditional statements like so:
if (BrowserDetect.browser.indexOf("chrome")>-1) {
document.write('<'+'link rel="stylesheet" href="../component/chromeCSSStyles.css" />');
} else if (BrowserDetect.browser.indexOf("mozilla")>-1) {
document.write('<'+'link rel="stylesheet" href="../component/mozillaStyles.css" />');
} else if (BrowserDetect.browser.indexOf("explorer")>-1) {
document.write('<'+'link rel="stylesheet" href="../component/explorerStyles.css" />');
}
Good luck and hope this helps!
You can use conditional comments to target IE browsers. Look at this: http://css-tricks.com/how-to-create-an-ie-only-stylesheet/. To target firefox you can check this answer: https://stackoverflow.com/a/953491/1941910. But I think there's no need to target firefox, chrome or safari, they all do a good job applying CSS.
you can do this at the server end.
if(Request.UserAgent is chrome){
//here output chrome stylesheet
}
I have a site http://test.printavo.com that renders terribly in IE8 but fine in IE7 and IE9. I'm not sure if IE8 has different standards for some reason but the main issue is that the text-shadow for 'Open Sans' Google font looks terrible...
Anyone have a fix for this? Maybe convert all fonts to Arial, I tried to text-shadow:none !important for IE but that didn't work (check out my source)
EDIT:
Is there a better way to take off all text-shadows in IE?
http://www.useragentman.com/blog/2011/06/29/full-css3-text-shadows-even-in-ie/
It would seem there are a variety of choices to choose from. The link above should give you some options. I should note they say IE8 can display text-shadow unpredictably and you should look the caveats section (link below) to try some fixes.
http://www.useragentman.com/blog/2011/04/23/css-blurred-text-shadow-in-ie-part-i/#caveats
EDIT:
In request to your browser specific css styling, you can target IE styling using conditional comments, just add this line to the >head< tags of your HTML file:
<!--[if IE 6]><link rel="stylesheet" href="http://mysite.com/path/to/ie6.css" type="text/css" media="screen, projection"><![endif]-->
<!--[if IE 7]><link rel="stylesheet" href="http://mysite.com/path/to/ie7.css" type="text/css" media="screen, projection"><![endif]-->
<!--[if IE 8]><link rel="stylesheet" href="http://mysite.com/path/to/ie8.css" type="text/css" media="screen, projection"><![endif]-->
<!--[if IE 9]><link rel="stylesheet" href="http://mysite.com/path/to/ie9.css" type="text/css" media="screen, projection"><![endif]-->
I need a concrete if statement that will work in an .aspx file (default.aspx) that I am building, the file itself serves as my homepage. I have not moved onto further pages. I currently catering for IE8 + 7, FireFox and Chrome.
I seem to be noticing issues in layouts even though in my markup I have this:
<!-- <link rel="stylesheet" type="text/css" href="css/homepageStyes.css" /> -->
<!--[if gt IE 6]>
<link rel="stylesheet" type="text/css" href="css/ie.css" />
<![endif]-->
Whenever I comment out either line of code, my layout problems go away but at the moment I reckon the mark up posted above is not concrete enough in telling a browser which style sheet it is to attach?
I need something along the lines of but in XHTML mark up ofc:
if (browser == "ie" || browser != "ie6") // not supporting ie6
{
// attach this style sheet:
// <link rel="stylesheet" type="text/css" href="css/ie.css" />
}
else
{
// attach this style sheet:
// <link rel="stylesheet" type="text/css" href="css/homepageStyes.css" />
}
I'm a C# developer so this is my first time building a website from scratch. So the C# if statement above was a good way of explaining what I need.
Use these conditional comments:
<!--[if gt IE 6]>
<link rel="stylesheet" type="text/css" href="css/ie.css" />
<![endif]-->
<!--[if !IE]><!-->
<link rel="stylesheet" type="text/css" href="css/homepageStyles.css" />
<!--><![endif]-->
The <!--[if gt IE 6]> comment ensures only IEs newer than version 6 will process and link to ie.css.
The <!--[if !IE]> tells IE to ignore what's in that conditional comment. The <!--> that directly follows is to terminate the if !IE component while maintaining a valid document. Anything past that will be read by other browsers and parsed, so homepageStyles.css will be linked to.
The second <!--> opens a comment so that IE can safely read the <![endif]--> that directly follows.
I have a regular CSS file plus two IE specific CSS files. In Firebug in Firefox I noticed the same <div> is getting properties from the three files.
Why is Firefox loading iestyle.css & ie6style.css?
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" media="all" href="iestyle.css" />
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" media="all" href="ie6style.css" />
<![endif]-->
Addition
This should definitely be working. Are you sure there isn't an unclosed <!-- or <![CDATA[ hanging around in head?
I think that isn't all the relevant code. Do you perhaps #include those files somewhere else?
Are the conditional comments in the HEAD element or in the BODY element? I haven't tried it, but it's possible that FF only ignores conditional comments if they are in the HEAD element (where they should be).
I have a a conditional comment in my page to fix a double padding-top problem with IE7.
I am trying to add "padding-top:5px;" to a DIV only in IE7. The rest of the browsers (including IE6 and IE8) use "padding-top:10px;" contained in stylesheet.css.
stylesheet.css contains
.clImageSamplerText {padding-top:10px;}
stylesheet_ie7.css contains
.clImageSamplerText {padding-top:5px;}
If I use
<link href="stylesheet.css" rel="stylesheet" type="text/css">
<!--[if IE 7]>
<style>.clImageSamplerText {padding-top:5px;}</style>
<![endif]-->
my code works no problem.
If I use
<link href="stylesheet.css" rel="stylesheet" type="text/css">
<!--[if IE 7]>
<link href="stylesheet_ie7.css" rel="stylesheet" type="text/css">
<![endif]-->
it does not work.
Anyone have any ideas?
Just a shot in the dark -- if you are using an XHTML doctype, you might find that closing your <link /> tags will fix the problem.
So try:
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="stylesheet_ie7.css" />
<![endif]-->
I have included link elements in conditional comments without any problems before, so I don't think it matters that you do that instead of writing it out in a style element. My best guess is that the document is not finding stylesheet_ie7.css. Are you sure it got uploaded to the right place?