1

One of the sites I am developing is loading an external stylesheet:

@import url(http://www.othersite.com/stylesheet.css);

This works in every single browser properly, except for Safari. Safari does not even try to load it. What am I doing wrong?

MKUltra
  • 73
  • 3
  • 10

2 Answers2

1

Could it have to do with this old bug: http://www.thinkoomph.com/thinking/2011-04/odd-css-bug-in-webkit-and-safari-4/ ?

The solution is simple. My @import directive was surrounded by other CSS instructions. Whereas IE tolerates this, the actual W3C spec declares that @import directives should appear before any other CSS instructions, and Firefox honors this restriction. Thus, my @import directive was being ignored. I moved it to the top of the file and everything started working.

and

At most one @charset rule may appear in an external style sheet — it must not appear in an embedded style sheet — and it must appear at the very start of the document, not preceded by any characters.

Grimace of Despair
  • 3,436
  • 26
  • 38
  • I'm not sure that this is the case in my instance, as all the other @import statement before this one are treated fine, recognized and loaded. Perhaps because this is the last entry in my master stylesheet file that may have caused an issue? – MKUltra Oct 04 '12 at 04:04
0
<link rel="stylesheet" type="text/css" href="http://www.othersite.com/stylesheet.css" />

I stumbled upon the solution while reading an article that details the pros and cons of using @import vs. tag. I tried using a tag instead of @import, and for whatever reason this solved my issue. Safari will now load the stylesheet. If anyone has any insight into why this works please comment :)

MKUltra
  • 73
  • 3
  • 10
  • I was going to suggest this as a solution in comments above and ask you why you decided to use `@import` rather than the more common `link` tag. – Sparky Oct 03 '12 at 21:05
  • The reason with sticking with @import instead of link, is because link will not properly cascade as far as I am aware. Does that make sense? – MKUltra Oct 04 '12 at 04:07