@import

  • Revision slug: CSS/@import
  • Revision title: @import
  • Revision id: 20217
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment 25 words added, 14 words removed

Revision Content

Summary

@import allows users to import style rules from other style sheets.

Syntax

@import "url";
@import "url" media1, media2, ...;
@import url("url");
@import url("url") media1;

Notes

So that user agents can avoid retrieving resources for unsupported media types, authors may specify media-dependent @import rules. These conditional imports specify comma-separated media types after the URI. In the absence of any media types, the import is unconditional. Specifying all for the medium has the same effect.

Examples

@import url("fineprint.css") print;
@import url("bluish.css") projection, tv;

Specifications

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatUnknownVersion() }} {{ CompatUnknownVersion() }} 5.5 {{ CompatUnknownVersion() }} {{ CompatUnknownVersion() }}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknownVersion() }} {{ CompatUnknownVersion() }} 5.5 {{ CompatUnknownVersion() }} {{ CompatUnknownVersion() }}

See also

{{ languages( {  "de": "de/CSS/@import", "fr": "fr/CSS/@import", "ja": "ja/CSS/@import", "pl": "pl/CSS/@import" } ) }}

Revision Source

<h2>Summary</h2>
<p><code>@import</code> allows users to import style rules from other style sheets.</p>
<h2 name="Syntax">Syntax</h2>
<pre class="eval">@import "<em>url</em>";
@import "<em>url</em>" <em>media1</em>, <em>media2</em>, <em>...</em>;
@import url("<em>url</em>");
@import url("<em>url</em>") <em>media1</em>;
</pre>
<h2 name="Notes">Notes</h2>
<p>So that user agents can avoid retrieving resources for unsupported media types, authors may specify media-dependent <code>@import</code> rules. These conditional imports specify comma-separated <a href="/en/CSS/@media#Media_types" title="en/CSS/@media#Media_types">media types</a> after the URI. In the absence of any media types, the import is unconditional. Specifying <code>all</code> for the medium has the same effect.</p>
<h2 name="Examples">Examples</h2>
<pre class="eval">@import url("fineprint.css") print;
@import url("bluish.css") projection, tv;
</pre>
<h2 name="Specifications">Specifications</h2>
<ul> <li><a class="external" href="http://www.w3.org/TR/REC-CSS1#the-cascade">CSS 1</a></li> <li><a class="external" href="http://www.w3.org/TR/CSS21/cascade.html#at-import">CSS 2.1</a></li>
</ul>
<h3 name="Browser_compatibility">Browser compatibility</h3>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Chrome</th> <th>Firefox (Gecko)</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatUnknownVersion() }}</td> <td>{{ CompatUnknownVersion() }}</td> <td>5.5 <a class="external" href="http://msdn.microsoft.com/en-us/library/cc351024%28v=vs.85%29.aspx" title="http://msdn.microsoft.com/en-us/library/cc351024%28v=vs.85%29.aspx"></a></td> <td>{{ CompatUnknownVersion() }}</td> <td>{{ CompatUnknownVersion() }}</td> </tr> </tbody> </table>
</div>
<div id="compat-mobile"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Mobile</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatUnknownVersion() }}</td> <td>{{ CompatUnknownVersion() }}</td> <td>5.5 <a class="external" href="http://msdn.microsoft.com/en-us/library/cc351024%28v=vs.85%29.aspx" title="http://msdn.microsoft.com/en-us/library/cc351024%28v=vs.85%29.aspx"></a></td> <td>{{ CompatUnknownVersion() }}</td> <td>{{ CompatUnknownVersion() }}</td> </tr> </tbody> </table>
</div>
<h2 name="See_also">See also</h2>
<ul> <li><a href="/en/CSS_Reference" title="CSS Reference">CSS Reference</a></li> <li>{{ CSS_at_rules() }}</li>
</ul>
<div class="noinclude"> <p>{{ languages( {  "de": "de/CSS/@import", "fr": "fr/CSS/@import", "ja": "ja/CSS/@import", "pl": "pl/CSS/@import" } ) }}</p>
</div>
Revert to this revision