Back to Content

CSSImportRule: href property

files/en-us/web/api/cssimportrule/href/index.md

latest812 B
Original Source

{{APIRef("CSSOM")}}

The read-only href property of the {{domxref("CSSImportRule")}} interface returns the URL specified by the {{cssxref("@import")}} at-rule.

The resolved URL will be the href attribute of the associated stylesheet.

Value

A string.

Examples

The following stylesheet includes a single {{cssxref("@import")}} rule. Therefore the first item in the list of CSS rules will be a CSSImportRule. The href property returns the URL of the imported stylesheet.

css
@import "style.css" screen;
js
const myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].href); // 'style.css'

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}