@import

HTML (DHTML)

@import Rule

Internet Development Index

Imports an external style sheet.

Syntax

HTML@import [url] ( sUrl ) ;
ScriptingN/A

Possible Values

sUrlString that specifies the URL that references a cascading style sheet.

Remarks

The rule has no default value.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties.

The semicolon in the syntax is required; if omitted, the style sheet is not imported properly and an error message is generated. "url()" is optional because there is always a URL following "@import."

The @import rule, like the link element, links an external style sheet to a document. This helps the Web author establish a consistent "look" across multiple HTML pages. Whereas the link element specifies the name of the style sheet to import using its href attribute, the @import rule specifies the style sheet definition inside a link element or a style element. In the scripting model, this means the owningElement property of the style sheet defined through the @import rule is either a style or a link object.

The @import rule should occur at the start of a style sheet, before any declarations. Although Internet Explorer 4.0 and later allows @import rule statements to appear anywhere within the style sheet definition, the rules contained within the @import rule style sheet are applied to the document before any other rules defined for the containing style sheet. This rule order affects expected rendering.

Rules in the style sheet override rules in the imported style sheet.

Examples

The following example uses the @import rule to import a style sheet. For the example to work, you must replace URL in the example code with the address of a style sheet.

<STYLE TYPE="text/css">
@import url("URL");
P {color:blue}
</STYLE>

The following example, without url(), has the same effect as the previous example.

<STYLE type="text/css">
@import "URL";
P {color:blue}
</STYLE>

Standards Information

This rule is defined in Cascading Style Sheets (CSS), Level 1 (CSS1) Non-Microsoft link.

See Also

imports, :link, style, styleSheet