1

This W3C draft (from 2002) mentions an intriguing way of having scoped CSS (apparently in HTML 4) using the style attribute and the @import statement in CSS. More precisely, they give the following example (example 4, section 2)

  1. Importing a style sheet to apply as a scoped style sheet:
<div class="navigation">
          style="@import url(navigationstyles.css);">...</div>

This document defines ... and scoped style sheets (the use of >@import which apples the referenced style sheet to the subdocument >consisting of the element and its children with the element as the root, >example 4).

Now, the problem is: it doesn't work (even after removing the obvious syntax error). Using the @import statement in the style attribute has absolutely no effect (in recent versions of Safari and Firefox).

So my question is: did the authors of this draft just make a mistake, or is this example correct and I'm just missing something?

3
  • why you have an '>' after your class ending ? it should be <div class="navigation" style="@import url(navigationstyles.css);">...</div> Commented Jun 19, 2016 at 22:05
  • Because I quoted the example verbally, including the 'obvious syntax error' I mentioned. Commented Jun 19, 2016 at 22:07
  • 1
    They probably removed it Commented Jun 19, 2016 at 22:11

1 Answer 1

1

There is a newer version of that specification (from 2013) which is a Recommendation instead of a Draft. The example you quote has been removed.

The authors didn't make a mistake. They wrote a draft which was later revised.

Sign up to request clarification or add additional context in comments.

1 Comment

Seems so, unfortunately :(Latest version gives the following grammar for values of "style": declaration-list : S* declaration? [ ';' S* declaration? ]*; In particular, no @import is allowed :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.