Re: <option>'s alignment and dir Re: Additional Requirements for Bidi in HTML - open issues

On 05/20/2010 11:41 AM, Xiaomei Ji wrote:
> I have some questions on <option>'s alignment.
>
> In 3.7 <option> should support the dir attribute and be displayed
> accordingly both in the dropdown and after being chosen. The proposed
> solution on alignment is: "setting an <option> element's alignment via
> CSS or the align attribute will affect its display accordingly in both
> the dropdown and after being chosen".
>
> Since "text-align" is inherited, if an <option>'s alignment is set, it
> is honored. If an <option>'s alignment is not set, it should take its
> <select>'s alignment if it is set.
>
> But how about the case when alignment is not set in both <option> and
> <select>? Should the alignment be derived from <option>'s dir or from
> <select>'s dir?
>
> For example:
> <select dir="rtl">
> <option style="text-align:right">foo</option>
> <option dir="ltr">bar</option>
> </select>
>
> "foo" is aligned right.
> "bar" is displayed as left-to-right both in dropdown and after being
> chosen. How about its alignment?
>
>
> The proposal also says that "an <option> element's computed direction
> will take its dir attribute into account, and will be used to display
> the option's text in both the dropdown and after being chosen". Does it
> mean if dir is set for <option>, it is honored, otherwise, the direction
> of <option> is computed (as what Safari does) without inherits from dir
> of <select>?

In CSS3, there is a text-align value called 'start', which represents
the default behavior. It inherits as 'start' and computes against the
current element. So if I don't specify text-align, it will be 'start',
and 'start' will inherit from the <select> to all the <option>s. When
layout happens, 'start' will behave as 'left' or 'right' depending
on the direction.

So, according to the specs, for this case
   <select dir="rtl">
     <option dir="ltr">Option A
     <option>Option B
   </select>
Option A will be left-aligned, and option B right-aligned.

~fantasai

Received on Thursday, 20 May 2010 20:04:11 UTC