Re: @import -- allow at any place in stylesheet.

2012/1/17 Marat Tanalin | tanalin.com <mtanalin@yandex.ru>:
> 17.01.2012, 22:49, "Tab Atkins Jr." <jackalmage@gmail.com>:
>> 2012/1/17 Marat Tanalin | tanalin.com <mtanalin@yandex.ru>:
>>>  @imports could be allowed at least exactly at the end of stylesheet. Currently, to achieve same result, we are often forced to make order of including less logical. For example, we have main.css linked to HTML document, and override.css imported to main.css. We want that rules from override.css would override main.css rules with same specificity. For this purpose, rules from override.css have to appear in cascade _after_ rules from main.css. We could do this usable way:
>>>
>>>     <link rel="stylesheet" href="main.css" />
>>>
>>>     main.css:
>>>         /* ...
>>>            Some rules to be overridden.
>>>            ... */
>>>         @import "override.css";
>>>
>>>  But currently we are forced to link to override.css instead of main.css to HTML document, and import main.css at the beginning of override.css:
>>>
>>>     <link rel="stylesheet" href="override.css" />
>>>
>>>     override.css:
>>>         @import "main.css";
>>>         /* ...
>>>            Some rules that override rules from main.css.
>>>            ... */
>>>
>>>  All that just decreases flexibility.
>>
>> The latter pattern is actually quite natural and easy to understand,
>> if you use different file names.  Instead of "main.css", call it
>> "template.css" or "defaults.css", and then instead of "override.css"
>> just call it "main.css".  It's then obvious and natural that you'd
>> directly reference the second file, and include the first file at its
>> top.
>
> The thread is not about naming, but about flexibility.

Naming is relevant here, because you are asserting that the pattern
where "override.css" includes "main.css" is unnatural.  I pointed out
that it's only unnatural because of the way the names you used are
directing your assumptions.  With different names, it's perfectly
sensible.


>> Alternately, this works today:
>>
>> <style>
>> @import "main.css";
>> @import "override.css";
>> </style>
>
> We can't, we are _forced_ to.
>
> It would be nice improvement of core CSS syntax if web-developers would get able to link to one CSS file in HTML document, and then to flexibly control cascading on pure CSS level.

What is wrong with the fragment I provided above?

~TJ

Received on Tuesday, 17 January 2012 21:02:34 UTC