This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 21188 - Default styles should not set direction on every element
Summary: Default styles should not set direction on every element
Status: VERIFIED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-04 15:43 UTC by Aharon Lanin
Modified: 2013-06-10 10:58 UTC (History)
6 users (show)

See Also:


Attachments

Description Aharon Lanin 2013-03-04 15:43:39 UTC
Currently, the (normative) section on the bidi aspects of the default style sheet (http://www.whatwg.org/specs/web-apps/current-work/multipage/rendering.html#bidirectional-text) contains, among other items, the following:

:dir(ltr) { direction: ltr; }
:dir(rtl) { direction: rtl; }

If I understand it correctly, it assigns a value to the direction style of *every* element (since every element has a directionality, as defined in http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#the-directionality, and the :dir() pseudoclass works off that directionality).

This means that, in effect, the direction style will no longer be inherited, but re-set to HTML's idea of the element's directionality. Thus, if we have:

<html><body style="direction:rtl;"><p>...</p></body></html>

the p's direction style will be reset to ltr, the directionality that it inherits from the html element, since the setting of the direction style on the body does not affect its or its descendants directionality.

AFAIK, this is not the way that any browser works today, and if implemented will break pages that, despite various recommendations, use CSS (and not markup) to set direction.

Previous versions of this section did not set the direction style on all elements as above, but only on elements with a dir attribute. I think that this needs to be reverted.
Comment 1 Ian 'Hixie' Hickson 2013-04-12 22:33:10 UTC
This change was made for bug 10808.

Tab: Should we use [dir]:dir(...) rather than just :dir(...), given the above ?
Comment 2 Simon Montagu 2013-04-13 18:22:17 UTC
I also think the default style sheet is wrong here. What Mozilla currently has is (edited for clarity)

[dir="rtl"] { direction: rtl; }
[dir="ltr"] { direction: ltr; }
bdi:dir(ltr), [dir="auto"]:dir(ltr) { direction: ltr; }
bdi:dir(rtl), [dir="auto"]:dir(rtl) { direction: rtl; }

which I suppose is also not quite right since the last two lines include bdi explicit dir="ltr" or dir="rtl" but should not.
Comment 3 fantasai 2013-04-13 19:38:56 UTC
smontagu, wouldn't just this be sufficient?
  [dir]:dir(rtl) { direction: rtl; }
  [dir]:dir(ltr) { direction: ltr; }

It does mean that we force-set 'direction' on elements that have invalid 'dir' values, but I don't think that's really a problem.
Comment 4 Ian 'Hixie' Hickson 2013-06-03 23:14:26 UTC
I went with comment 1 / comment 3.
Comment 5 contributor 2013-06-03 23:16:38 UTC
Checked in as WHATWG revision r7887.
Check-in comment: Shouldn't force-set 'direction' on every element, only those that mention dir=''.
http://html5.org/tools/web-apps-tracker?from=7886&to=7887
Comment 6 Aharon Lanin 2013-06-04 06:18:13 UTC
(In reply to comment #4)
> I went with comment 1 / comment 3.

Simon is right in comment 2 that the way things stand, <bdi> got short-changed. <bdi> and <bdi="auto"> are supposed to be exactly the same. However, we now set direction on <bdi="auto">, which is good, but do not set direction on <bdi>. Thus, I believe it should be:

  [dir]:dir(rtl), bdi:dir(rtl) { direction: rtl; }
  [dir]:dir(ltr), bdi:dir(ltr) { direction: ltr; }
Comment 7 contributor 2013-06-06 22:15:10 UTC
Checked in as WHATWG revision r7930.
Check-in comment: Make <bdi> always set 'direction'
http://html5.org/tools/web-apps-tracker?from=7929&to=7930