{"id":260,"date":"2010-03-22T02:45:58","date_gmt":"2010-03-21T23:45:58","guid":{"rendered":"http:\/\/www.held.org.il\/blog\/?p=260"},"modified":"2012-05-21T02:22:45","modified_gmt":"2012-05-20T23:22:45","slug":"off-left-convention-is-bad-news-for-rtl","status":"publish","type":"post","link":"http:\/\/www.held.org.il\/blog\/2010\/03\/off-left-convention-is-bad-news-for-rtl\/","title":{"rendered":"&quot;off-left&quot; convention is bad news for RTL"},"content":{"rendered":"<p><span style=\"color: #888888;\"><strong>[This post presents a web designers technical problem, in which a hack for improved accessibility damages RTLability]<\/strong><\/span><\/p>\n<p>This weekend I tried to debug an annoying problem in <a href=\"http:\/\/www.drupal.org\">Drupal<\/a>'s <a href=\"http:\/\/drupal.org\/project\/acquia_marina\">Acquia Marina<\/a> theme on <a href=\"http:\/\/en.wikipedia.org\/wiki\/Right-to-left\">RTL<\/a> mode, in which a horizontal scroll bar appears with no good reason (layout doesn't scale horizontally).<\/p>\n<p>I turned to monkey HTML debugging, a term I just invented for removing element-by-element until getting to a super simple HTML file which reproduces the bug.<\/p>\n<p>Eventually the one to blame was an element placed at <strong>\"left: -999em\"<\/strong> absolute position,\u00c2\u00a0 a far place horizontally, and triggered the scroll bar to appear (on FF and IE, not on Chrome). When on LTR mode, it didn't, and things work perfectly. This setting aims to simply hide the drop-down menu when mouse is not hovering above it.<\/p>\n<p><strong>Q: Why don't they use CSS display:none,<\/strong> which seems to make more sense than hiding things off the screen?<\/p>\n<p><strong>A<\/strong>: looks like it has to do with screen readers (as <a href=\"http:\/\/css-discuss.incutio.com\/wiki\/Screenreader_Visibility#Late_Breaking_Breakthrough\">this article<\/a> suggests), which are apparently not aware of display:none text but are aware of off-screen text. A little puzzling. <strong>I suspect that it's too old info<\/strong>, for it seems to be written on 2003. I wonder if new screen readers have this problems as well, and whether the reason for using off-left is not just an ancient myth.<\/p>\n<p><strong>The problem with RTL<\/strong><\/p>\n<p>When placing things off-left (e.g. <em>left: -999px<\/em>) on LTR mode, all browsers do NOT widen the page horizontally. It makes sense - the page goes from left to right, not from left to even-more left.<\/p>\n<p>However, when on RTL mode, <em>left: -999px<\/em> <strong>does<\/strong> widen the page horizontally to the right (and the off-left element is actually visible when scrolling there), which is a very unwanted effects.<\/p>\n<p>Here's <a href=\"http:\/\/www.held.org.il\/blog\/?p=260\">a related drupal discussion<\/a> about the problem and possible solutions.\u00c2\u00a0 The problem seems <a href=\"http:\/\/drupal.org\/node\/725840\">broader than just acquia marina<\/a> .<\/p>\n<p><!--more--><\/p>\n<h3>Potential Solution #1: use off-right on RTL: BAD<\/h3>\n<p>That's the most trivial solution. It seems to work on IE8, chrome and FF. However, IE7, even on RTL, keeps widening the page and creating a horiz. scroll bar when using <em>right: -999px<\/em>. as for my inspection <strong>IE7 does not cope well with off-right<\/strong> (nor off-left) on RTL!<\/p>\n<p>Another, more minor downside, is that this solution requires different styling-code for LTR and RTL.\u00c2\u00a0 It's always preferred to have code that is not direction-specific, so that even when not keeping RTL in mind, the page would be RTL-compliant.<\/p>\n<h3>Potential solution #2: off-top<\/h3>\n<p>As far as I know, there are no TTB (Top To Bottom) languages on the web, so hiding things off top would be best. From my tests, all common browsers (IE7, IE8, chrome, FF) like it. I wonder why people didn't use it in first place instead of off-left, did I miss any disadvantage?<\/p>\n<h3>Long-term solution: an intuitive new standard<strong><br \/>\n<\/strong><\/h3>\n<p>Personally I believe that neither off-left, off-right nor off-top are intuitive, these looks more like hacks, and I bet that most web developers don't even know about these. So even, for the sake of accessibility, it's important to resolve this screen reader crisis (if it exists at all), and have an industry standard for setting elements as hidden.<\/p>\n<p>First step should be figuring out why\/whether screen readers don't support <em>display:none<\/em>; <strong>can readers confirm that and go into deeper details?<\/strong><\/p>\n<p>Second step might be fixing the standards so that screen readers would support it, if needed.<\/p>\n<p><strong>-----<br \/>\n<\/strong><\/p>\n<p><strong>And the patch for fixing the RTL horizontal-scroll bar bug in Drupal's Acquia Marina theme:<\/strong><\/p>\n<p>--- a\/style.css<br \/>\n+++ b\/style.css<br \/>\n@@ -1145,7 +1145,7 @@ div.rounded-inside {<\/p>\n<p>#primary-menu ul.menu li ul {<br \/>\nbackground: transparent url('images\/drop-bottom.png') no-repeat 0 bottom;<br \/>\n-\u00c2\u00a0 left: -999em;<br \/>\n+\u00c2\u00a0 top: -999em;<br \/>\nopacity: 0.95;<br \/>\nmargin: 0 0 0 -10px;<br \/>\npadding: 2px 0 4px;<br \/>\n@@ -1157,7 +1157,7 @@ div.rounded-inside {<br \/>\n#primary-menu ul.menu li:hover ul,<br \/>\n#primary-menu ul.menu li.hover ul {<br \/>\ndisplay: block;<br \/>\n-\u00c2\u00a0 left: auto;<br \/>\n+\u00c2\u00a0 top: auto;<br \/>\n}<\/p>\n<p>#primary-menu ul.menu li ul li {<br \/>\n@@ -1195,7 +1195,7 @@ div.rounded-inside {<br \/>\n}<\/p>\n<p>#primary-menu ul.menu li ul li ul.menu {<br \/>\n-\u00c2\u00a0 left: -999em;<br \/>\n+\u00c2\u00a0 top: -999em;<br \/>\nmargin: 0 0 0 -14px;\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 \/* LTR *\/<br \/>\npadding: 6px 0 4px;<br \/>\n}<br \/>\n@@ -1231,7 +1231,7 @@ div.rounded-inside {<br \/>\n}<\/p>\n<p>#primary-menu ul.menu li ul li ul.menu li ul.menu li ul.menu{<br \/>\n-\u00c2\u00a0 left: -999em;<br \/>\n+\u00c2\u00a0 top: -999em;<br \/>\nmargin: 0 0 0 -14px;<br \/>\npadding: 6px 0 4px;<br \/>\n}<\/p>\n<p><strong>Update: <\/strong>I have opened<a href=\"http:\/\/drupal.org\/node\/748938\"> a bug for acquia marina<\/a>, and found <a href=\"http:\/\/drupal.org\/node\/725840\">another related bug<\/a> (it's me commenting there about off-top).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[This post presents a web designers technical problem, in which a hack for improved accessibility damages RTLability] This weekend I tried to debug an annoying problem in Drupal&#8217;s Acquia Marina theme on RTL mode, in which a horizontal scroll bar appears with no good reason (layout doesn&#8217;t scale horizontally). I turned to monkey HTML debugging, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[15],"tags":[17,30,35,198,99,202],"_links":{"self":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts\/260"}],"collection":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/comments?post=260"}],"version-history":[{"count":0,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts\/260\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/media?parent=260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/categories?post=260"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/tags?post=260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}