Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css @import external style sheet

Tags:

import

css

If it possible to use @import in a .css file to load a style sheet from another site? Specifically, I have a main style sheet for my site which loads in other (local) style sheets using @import. I'd also like to load in a jquery ui theme hosted by google, e.g.

@import "http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css";

This does not seem to work - I wanted to check whether this is allowed before working out exactly where the problem is.

like image 672
Tomba Avatar asked Feb 27 '10 11:02

Tomba


People also ask

How do you add an external style sheet in CSS?

External CSS With an external style sheet, you can change the look of an entire website by changing just one file! Each HTML page must include a reference to the external style sheet file inside the <link> element, inside the head section.

Can you use @import in CSS?

The @import rule allows you to import a style sheet into another style sheet. The @import rule must be at the top of the document (but after any @charset declaration). The @import rule also supports media queries, so you can allow the import to be media-dependent.

What is external style sheet in CSS?

An external style sheet is a separate CSS file that can be accessed by creating a link within the head section of the webpage. Multiple webpages can use the same link to access the stylesheet. The link to an external style sheet is placed within the head section of the page.


1 Answers

That should work. Are you sure it is not loaded? What browsers does this happen in? Can you confirm using Firebug?

There is no mention of it not working in the w3 specs nor in the related MSDN Article (The latter applies to IE only of course).

According to those specs, adding url(...) around the address is optional, but try whether that yields better results.

like image 97
Pekka Avatar answered Sep 22 '22 13:09

Pekka