- From: Lea Verou <leaverou@gmail.com>
- Date: Fri, 06 Apr 2012 01:28:09 -0700
- To: www-style list <www-style@w3.org>
Up until recently, a defacto naming convention was followed for longhands: Every longhand property name had to start with the shorthand property name plus a hyphen. For example, all the properties the background shorthand consists of, start with "background-" and every property that starts with "background-" belongs to the "background" shorthand. This convention had quite a few benefits, including: 1. Scripts can use the browser-provided list of supported properties and instantly "know" which properties are shorthands and which longhands they consist of. Otherwise, scripts would need to have that information hardcoded which results in bloat and will quickly get out of date. 2. It makes it easier to teach CSS when things are predictable. 3. It makes it easier to understand CSS code even when the reader is not familiar with all the features used within. Unfortunately, this convention is not strictly followed anymore. I can count at least three violations off the top of my head: - css3-multicol: `columns` is the shorthand for `column-width` and `column-count` even though it doesn't start with `column-` [1] - css3-text: `white-space` is (kind of) a shorthand for `text-space-collapse` and `text-wrap`, even though neither of these properties start with `white-space-` [2]. Even worse, this one doesn't follow other established conventions as well: The individual values of the longhand properties are not allowed in their shorthand, only keywords that correspond to combinations thereof. I understand the need for backwards compatibility with existing values, but there is nothing preventing it from functioning as a regular shorthand *additionally* (e.g. white-space: preserve-breaks none; which is currently impossible with the keywords). - css3-transforms: `transform-origin` and `transform-style` is not part of a longhand for `transform` even though their naming suggests so. [3] Same with `perspective` and `perspective-origin` [4] I understand that it's too late to change most of these. What I'm suggesting is to: 1. Make the convention mandatory from now on, so that the number of violations does not increase. It's easier to deal with a rule that has few exceptions than to not have a rule at all. 2. Document the exceptions in an official list that script authors and trainers can use. [1]: http://www.w3.org/TR/css3-multicol/#columns [2]: http://dev.w3.org/csswg/css3-text/#text-space-collapse [3]: http://www.w3.org/TR/css3-transforms/#transform-property [4]: http://www.w3.org/TR/css3-transforms/#perspective-property -- Lea Verou (http://lea.verou.me | @LeaVerou)
Received on Friday, 6 April 2012 08:28:44 UTC