W3C home > Mailing lists > Public > www-international@w3.org > October to December 2009

Re: More best practices for RTL scripts (markup vs CSS for bidi).

From: Simon Montagu <smontagu@smontagu.org>
Date: Fri, 27 Nov 2009 08:54:56 +0200
Message-ID: <4B0F77C0.5020201@smontagu.org>
To: Adil Allawi <adil@diwan.com>
Cc: ntounsi@emi.ac.ma, Najib Tounsi <ntounsi@gmail.com>, "public-i18n-core@w3.org" <public-i18n-core@w3.org>, 'WWW International' <www-international@w3.org>
On 11/26/2009 05:09 PM, Adil Allawi wrote:
> Actually the reality is worse. Below is your page drawn in Gecko (Firefox) on
> the left and Webkit (Safari) on the right:
>
>
>
> There is a thread on this list started by Aharon from Google that talks about
> exactly theses sort of issues that has received too little discussion. The real
> problem is that the HTML standard is not explicit enough on what should happen
> so you will get different results on different browsers.
>
> Your example is in a fuzzy area. As far as the markup is concerned there are
> three distinct paragraphs but for the user there is one sentence. According to
> the HTML standard, the elements should be ordered according to the Unicode bidi
> algorithm, however that algorithm has nothing to say about what to do when lines
> of a paragraph are drawn inline. I would personally say that the Gecko engine is
> doing the right thing in this case.

I assume your Gecko example is using a very recent version of Gecko,
such as a nightly build or a beta of Firefox 3.6? I fixed this issue
only a few months ago.

The HTML standard does specify what to do in this case, see
http://www.w3.org/TR/REC-html40/struct/dirlang.html#style-bidi:

"When a block element that does not have a dir attribute is transformed
to the style of an inline element by a style sheet, the resulting
presentation should be equivalent, in terms of bidirectional formatting,
to the formatting obtained by explicitly adding a dir attribute
(assigned the inherited value) to the transformed element."

In practice, however, since browsers are not consistent, authors will 
have to use CSS properties to achieve the expected results.

>
> regards
>
> Adil
>
> On 25/11/2009 17:40, Najib Tounsi wrote:
>>  Dear all, and bidi experts
>>
>>  When trying to localize [1] the new W3C homepage style [2], I came across
>>  something worth to note.
>>
>>
>>  HTML markup (dir="rtl") doesn't have the same effect as CSS (direction:
>>  rtl;unicode-bidi: embed;)
>>
>>  Some time you want your block-element to display inline (e.g. for menu-like
>>  effect). However, by default this block elements flow from left to right. So
>>  to make them flow from right-to left, you want to use HTML markup (dir="rtl").
>>  It doesn't work. You should use CSS properties
>>  (direction: rtl; unicode-bidi: embed;) to get the desired effect.
>>
>>  with the following style:
>>
>>  <style type="text/css">
>>  .a p {display:inline; direction: rtl; unicode-bidi: embed}
>>  .b p {display:inline;}
>>  </style>
>>
>>  the HTML code (case-1):
>>
>>  <div class="a">
>>  <p>display</p>
>>  <p>in</p>
>>  <p>line</p>
>>  </div>
>>
>>  results in
>>  line in display
>>
>>  while (case-2):
>>
>>  <div class="b" dir="rtl">
>>  <p>display</p>
>>  <p>in</p>
>>  <p>line</p>
>>  </div>
>>
>>  will result in (right justified)
>>  display in line
>>
>>
>>  The point is: Why CSS 'direction: rtl; unicode-bidi: embed' is not the same as
>>  markup 'dir="rtl"'
>>
>>  Css vs markup FAQ [3] says (and I strongly agree):
>>  "You should always use dedicated bidi markup to describe your content, where
>>  markup is available [...] because directionality is an integral part of the
>>  document structure." This rule seems violated in the above example.
>>
>>  Well... why change writing direction when content is all English?
>>  But imagine one of the<p>  contains a strong RTL char.
>>
>>  The two cases are still different. In the second case (dir="rtl"), the result
>>  is like if all<p>s are inline elements, i.e. all inner<p>s are removed.
>>  Please try it: http://www.w3c.org.ma/Tests/displayInline.html
>>
>>  So, the rule seems to be (grossly paraphrased):
>>  For inline elements, CSS direction property applies to the ordering of
>>  elements as well as to their content. On the other hand, markup dir attribute
>>  applies only to the content of these elements juxtaposed together.
>>
>>  Any opinion?
>>
>>  [1] http://www.w3c.org.ma/Tests/temp-ar-index.html
>>  [2] http://www.w3.org/
>>  [3] http://www.w3.org/International/questions/qa-bidi-css-markup
>>
>>
>>  -----------------------------
>>  Note incidently, that elements displayed inline and floated right, will flow
>>  (by side effect) from right to left, whatever direction is specified. Does
>>  float style (*cancel*) direction style?
>>
>>  Try it: http://www.w3c.org.ma/Tests/inlineFloat.html
>>
>>
>>  Best regards,
>>
>>  Najib
>>
>>
Received on Friday, 27 November 2009 06:55:38 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 27 November 2009 06:55:40 GMT