W3C home > Mailing lists > Public > www-style@w3.org > August 2012

Re: Previous-sibling combinator

From: Marat Tanalin | tanalin.com <mtanalin@yandex.ru>
Date: Fri, 17 Aug 2012 18:59:24 +0400
To: "Kang-Hao (Kenny) Lu" <kanghaol@oupeng.com>
Cc: WWW Style <www-style@w3.org>
Message-Id: <631791345215564@web1g.yandex.ru>
17.08.2012, 07:52, "Kang-Hao (Kenny) Lu" <kanghaol@oupeng.com>:
> (12/01/28 7:05), Marat Tanalin | tanalin.com wrote:
>
>> The "-" combinator is functionally similar to existing "+"
>> combinator, but selects previous-sibling element instead of
>> next-sibling one.
>>
>> So in result we would have "+" to move forward, and "-" to move
>> backward (like element.nextSibling and element.previousSibling in
>> DOM, respectively).
>
> While I think this idea makes sense, using "-" would mean that you have
> to put spaces around "-". For example, compare
>
> x-element {} /* I am not following the Web Compoents work and I don't
> know if the x-prefix idea is still there */
>
> to
>
> x - element {}
>
> .
>
> I have no idea how big this concern is.

I'm fine with making spaces around `-` combinator required (BTW currently I always put spaces around combinators for the purpose of readability).

Take into account though, that there is escaping feature in CSS. For example, in HTML5, identifiers are allowed to contain characters that are special in CSS. So to be used in selectors, such special characters must be escaped:

    <div id="lorem+ipsum"></div>

    #lorem\+ipsum {/**/}

There is nothing why `-` should be different, it just should be escaped if it has no special meaning in a specific place of selector:

    x\-element {/**/}

See also:
http://www.456bereastreet.com/archive/201011/html5_allows_almost_any_value_for_the_id_attribute_use_wisely/
Received on Friday, 17 August 2012 15:00:19 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:58 GMT