Re: Custom property names: property name namespaces?

ewexler@stickdog.com wrote:
> Christian Roth wrote:
>> What is the recommended way to name these proprietary properties and
>> their values to avoid future name clashes when the standard defines new
>> properties and/or value sets?
>>
>> In the archives, it was recommended to use "-" as starting character
>> since it was not a valid CSS token start character, but there was also a
>> reference to CSS3.
> 
> The hyphen-minus, "-", may start certain tokens in CSS, but not identifier (IDENT) 
> tokens, which are what I assume you meant.
> 
> I warn against using an initial hyphen-minus to distinguish proprietary identifiers 
> because allowing this corrupts the lexer, a fundamental part of any CSS implementation.

The hyphen is the character recommended by the working group to use as prefixes 
for proprietary properties.

Specifically, the suggested syntax to use is:

    -vendor-property

For example,

    -moz-border-radius
    -mso-western-font-family

If the impact on the lexer is of great concern, then the working group suggests 
implementors use a leading underscore instead of a leading hyphen. No official 
W3C CSS property will ever start with an underscore. For example:

    _wap-marquee

Following these guidelines will ensure that you don't break future compatability 
of CSS with your implementation.


Note that the leading hyphen or underscore, and the vendor prefix, are both 
parts of the recommendation. Thus the following would be unrecommended forms to 
use as property names:

    -x-background-position-left       x is not the vendor
    -link                             no vendor prefix
    mso-quotes                        no leading hyphen
    text-underline-color              could clash with future properties
    position                          clashes with existing properties


Some more guidelines while I'm at it:

Additional values to existing properties should also be prefixed with the 
-vendor- string. Values to proprietary properties need not be.

Experimental implementations of working drafts should use the -vendor- prefix. 
Only once the spec has reached CR should implementations use the actual names as 
given in the spec.

This prevents chaos as caused by IE4's 'position' implementation, which was 
based on a draft which changed before CSS2 reached PR stage, and meant that 
documents written for IE4 totally broke on compliant implementations. This is, 
in fact, one of the main events that spurred on these guidelines.


(Note that with the exception of the first one, I'm making up these properties. 
Resemblence to real proprietary properties is intentional, but if they actually 
are real ones then that's a coincidence.)

-- 
Ian Hickson
``The inability of a user agent to implement part of this specification due to
the limitations of a particular device (e.g., non interactive user agents will
probably not implement dynamic pseudo-classes because they make no sense
without interactivity) does not imply non-conformance.'' -- Selectors, Sec13

Received on Sunday, 5 May 2002 14:23:50 UTC