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.

  :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:
- allows styling elements depending on their content
- avoids workarounds with JavaScript or semantic mark up

- 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:
  :contains( <string> | <regular expression> )


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


Any thoughts on this?

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 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:14 UTC