THE GITHTML FIELD GUIDE
Why an imported stylesheet is silently ignored
Check the position and conditions of an @import rule when its stylesheet appears to be ignored. Imports must occur before ordinary style rules, subject to the permitted preceding at-rules, and their media or support conditions must match. A successful parent stylesheet load does not prove that every imported stylesheet was loaded or applied.
Identify the specific failure
An export may concatenate CSS in an order that moves an import below a regular declaration. The browser can ignore that import even though the URL is valid. Nested imports also create a dependency chain that is easy to overlook.
Make a narrow correction
Inspect the first rules in the stylesheet and the imported request separately. Preserve the intended cascade order when moving or inlining rules. Simply pasting imported CSS at the end can change which declarations win and introduce a different visual result.
- Check import placement before investigating selector specificity.
- Inspect any media or supports condition attached to the import.
- When inlining, preserve relative order and rewrite resource URLs relative to their new location.
@import url("report-base.css");
.report { max-width: 70ch; }Separate import placement from loading and cascade failures
Consider a stylesheet that begins with body typography, followed by an import of its color theme. The typography applies but the theme does not. Move the import above ordinary style rules in a diagnostic copy and inspect one distinctive theme declaration. If that declaration now appears, the failure was placement, not a missing file. A layer-order statement can precede imports, but a layer block containing style rules is different. Avoid treating every at-rule as interchangeable when assembling styles from several sources.
If moving the import has no effect, check whether it has a media condition such as print or a supports condition that is false in the current environment. A conditional import may not be fetched when its condition does not match. That is different from a request that was sent and rejected. In the first case, examine the condition; in the second, examine the request and response. An import cannot simply be nested inside a media block as though it were an ordinary style rule.
Finally, distinguish a loaded rule from a winning rule. An imported declaration participates at the import's position in the cascade and may be overridden later. Inspect the specific property rather than using the overall theme color as a vague success signal. When consolidating the stylesheet for a reading copy, preserve that ordering and resolve its nested resource paths. A good small test includes one imported base rule and one intentional local override, demonstrating that both the dependency and the expected precedence survived the consolidation.
Verify the repaired artifact
Compare a distinctive rule from the imported file before and after the correction, rather than judging only the page's overall appearance.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.