- From: Marat Tanalin | tanalin.com <mtanalin@yandex.ru>
- Date: Wed, 18 Jan 2012 00:51:05 +0400
- To: Tab Atkins Jr. <jackalmage@gmail.com>
- Cc: www-style@w3.org
17.01.2012, 22:49, "Tab Atkins Jr." <jackalmage@gmail.com>: > 2012/1/17 Marat Tanalin | tanalin.com <mtanalin@yandex.ru>: > >> 17.01.2012, 20:14, "Tab Atkins Jr." <jackalmage@gmail.com>: >>> The restriction that @import has to appear at the top of a file is >>> meant, I believe, to make it easier to understand that other files are >>> being imported. A lone @import in the middle of a file is easy to >>> accidentally skip over for a human. >> It's wrong and harmful to try think for web-developers and invent artificial unusable limitations as a result. Web-developers themselves are capable to decide how to use syntax. Imports/includes in PHP, SSI, etc., are possible at any place, and this is not an issue there. > > Incorrect. We must always guard against making the language too > complicated when the reward is just better behavior in an edge case. There is no any complication here. We already have @import construct. We just should be able to insert it _between_ and _after_ rules and get rid of "only before other rules" theoretical limitation. And again (since apparently ignored): imports/includes in PHP, SSI, etc., are possible at any place, and this is not an issue there. >> @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. > 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.
Received on Tuesday, 17 January 2012 20:51:40 UTC