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

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">
   <h1>Hello</h1>
</body>

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">
   <body>
      ...
         ...
            <ul>
               <li>...</li>
            </ul>
         ...
      ...
   </body>
</html>

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.

http://terrainformatica.com

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