Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I mix hebrew and latin text in a HTML document?

I have a html document that contains hebrew and latin text. It is encoded with utf-8:

<!DOCTYPE HTML>
<html>
<head>
  <title>Title</title>
  <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
</head>

<style type='text/css'> 
     .h  { color: green}
</style>

<body>

   <div>
      here are some words הנה כמה מילות (100, 200)
   </div>

   <div>
      here are some words <span class='h'>הנה כמה מילות</span> (100, 200)
   </div>

   <div>
      here are some words <span class='h'>הנה כמה מילות</span> <span>(100, 200)</span>
   </div>

   <div>
      here are some words <span class='h'>הנה כמה מילות</span> <b>WORD</b> <span>(100, 200)</span>
   </div>

</body>
</html>

The first three lines are not displayed as I think they should. The fourth (with the additional <b>WORD</b> in front of the parantheses is.

Here's how this document is displayed in Firefox:

Firefox' rendeering

Edit Not even the copy/paste of my html text works correctly, so here's a screen shot of the original html (sorry, but it seems as though it's impossible to get this text rendered correctly):

enter image description here

like image 624
René Nyffenegger Avatar asked Apr 06 '14 15:04

René Nyffenegger


People also ask

How to make text RTL in HTML?

Setting up a right-to-left pageAdd dir="rtl" to the html tag any time the overall document direction is right-to-left (RTL). This sets the default base direction for the whole document. All block elements in the document will inherit this setting unless the direction is explicitly overridden.

Which attribute is used to set the text display position on the output screen?

The dir attribute is used to set the base direction of text for display.


1 Answers

When you have words in Latin and Hebrew letters mixed on the same page, the sequences of words are normally written properly due to the inherent directionality of characters. Hebrew passages run right to left.

But when characters like parentheses are involved, things get more complicated. Parentheses are directionally neutral (or utral) and participate in the direction of adjacent characters. Problems arise when they appear between Latin and Hebrew letters. A simple remedy is to use the LEFT-TO-RIGHT MARK character, representable in HTML as &lrm;, for example

here are some words <span class='h'>הנה כמה מילות</span> &lrm;(100, 200)
like image 149
Jukka K. Korpela Avatar answered Sep 23 '22 16:09

Jukka K. Korpela