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

[css-selectors] :contains()

From: Sebastian Zartner <sebastianzartner@gmx.de>
Date: Tue, 17 Apr 2012 15:06:45 +0200
Message-ID: <20120417130645.61790@gmx.net>
To: www-style@w3.org
There's a discussion at https://bugzil.la/221981 about adding the :contains() pseudo-class selector to the Mozilla CSS core.
According to Ian Hickson (http://lists.w3.org/Archives/Public/www-style/2005Dec/0155.html) and David Baron (https://bugzil.la/221981#c15) this feature was dropped from the spec due to a lack of implementations.
This mail aims for a re-introduction of :contains() into the spec and to discuss its implementation.

Syntax:
  :contains( <string> )

Possible use cases for :contains() are:
- styling negative numbers (https://bugzil.la/221981#c30)
- highlighting Sundays in a calendar
- highlighting search matches in a table
- hiding parts of a page (https://bugzil.la/221981#c4)

The discussion mentions several pros and cons regarding its implementation:
Pro:
- allows styling elements depending on their content
- avoids workarounds with JavaScript or semantic mark up

Contra:
- introduces security issues (https://bugzil.la/221981#c12)
- slows down page speed (https://bugzil.la/221981#c3)


So far only simple substring matches were discussed in https://bugzil.la/221981.
Though the functionality of :contains() could be further enhanced by:

1. allowing to match regular expressions:
Syntax:
  :contains( <string> | <regular expression> )

Example:
  .author:contains(/owner|committer/)

2. allowing to use it as parent selector:
Syntax:
  :contains( <string> | <selector> )

Example:
  #thread:contains(.deletedPost)

Any thoughts on this?

Sebastian
-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
Received on Tuesday, 17 April 2012 13:07:21 GMT

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