W3C home > Mailing lists > Public > www-style@w3.org > March 2008

Re: [CSS3] ltr and rtl pseudo-class proposal

From: Andrew Fedoniouk <news@terrainformatica.com>
Date: Mon, 17 Mar 2008 00:43:37 -0700
Message-ID: <47DE2129.9020708@terrainformatica.com>
To: Alan Gresley <alan@css-class.com>
CC: www-style@w3.org, robert@ocallahan.org

Alan Gresley wrote:
> Andrew Fedoniouk wrote:
>> Nothing wrong in principle.
>> div:ltr will match any element that has or is
>> inside element with dir="ltr" defined explicitly. So
>>    div:ltr { direction:rtl; }
>> simply means that in this particular div author wants
>> to see rtl text despite of possible ltr environment.
>> May or may not have any sense. The same as here:
>>    div[dir="ltr"] { direction:rtl; }
> Hi Andrew, I guess you missed my initial reply.
> http://lists.w3.org/Archives/Public/www-style/2008Mar/0207.html

I simply forgot to respond, my pardon.

> Anyhow, to put an end to this whatever, please see this text case.
> http://css-class.com/test/css/selectors/attribute-dir1.htm
> [dir="ltr"] {background:red}
> [dir="ltr"] [dir="rtl"] {background:blue}
> It will work in most UAs.

Alan, first of all you've forgot about the case:

<body dir="rtl">

and the second:

Selector *:rtl means exactly following:
"element that has nearest parent (including itself)   with defined 
attribute @dir and that @dir attribute has exactly "rtl" value.

In other words: :rtl matches *any* element in rtl environment 
established by itself or one of its parents.

That is different from what you have defined.

I would like to be able to define

ul { padding:0 0 0 20px; }
ul:rtl { padding:0 0 20px 0; }

in "master style sheet" so this will cover all cases.

It is not possible to build equivalent of proposed :rtl by
using solely [dir="ltr"] for any DOM tree and any element inside it.

<html dir="rtl">

That will require infinite set of rules:

[dir="ltr"] [dir="rtl"] * {background:blue}
[dir="ltr"] [dir="ltr"] [dir="rtl"] * {background:blue}
[dir="ltr"] [dir="rtl"] [dir="rtl"] * {background:blue}

In general request "element with nearest parent having defined A of 
exactly value S" is not solvable in terms of CSS selectors for arbitrary 
elements / DOM trees.

Andrew Fedoniouk.

Received on Monday, 17 March 2008 07:44:10 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:34 UTC