- From: Benjamin Poulain <bpoulain@apple.com>
- Date: Mon, 10 Nov 2014 20:40:59 -0800
- To: www-style list <www-style@w3.org>
Hi, It looks like it would be useful to include :only-of(selector list) in Selectors Level 4. It is already possible to achieve the same behavior by using :nth-child(1 of selector list):nth-last-child(1 of selector list) but that is significantly uglier. Repeating the selector list is error prone when updating the stylesheet and the specificity is doubled. The selector :only-of(selector list) would behave like :nth-child(1 of selector list):nth-last-child(1 of selector list) but with lower specificity (accounting for the selector list once instead of duplicating it). The definition of :only-of-type is pretty much the same. The implementation is trivial based on the existing :nth-child() and :nth-last-child(). The single :only-of() is likely to be more efficient than :nth-child():nth-last-child() in most implementations. Benjamin
Received on Tuesday, 11 November 2014 04:42:15 UTC