Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML CSS Styling for Hebrew Niqqud

Tags:

html

css

hebrew

I'd like to style niqqud characters inside html differently than the letter. Suppose I'd like to have Hebrew letter Bet black while Dagesh in it green.

How can this be made in html+css?

This doesn't do the task:

<div style = "font-size: 500%">
    <span style = "color: black">&#1489;</span><span style = "color: red">&#1468;</span>
</div>

It results in : http://jsfiddle.net/nv7ja459 (link with bigger font: http://jsfiddle.net/nv7ja459/1/)

So the dagesh is no more inside the letter.

Link to screenshot https://drive.google.com/file/d/0B4SYIrNV4hXYZ0ZyWXZnZWg4OGc/view?usp=sharing

like image 745
leokom Avatar asked Dec 29 '14 15:12

leokom


1 Answers

The main issue here is that when you wrap the dagesh, niqqud or other diacritic in a span (to style it) - the browser no longer knows which consonant it was attached to.

Because of this, it cannot position it correctly. For example, vav is much narrower than shin. Let's say the browser positions qamats 5px to the right when attached to a vav and 10px to the right when attached to a shin. When you wrap qamats in a span the browser does not know which consonant it is attached to and therefore does not know how far to move it to the right. So it just gives up and doesn't move it to the right at all. Hence, why, when you wrap vowels, etc in a span the position is messed up.

You can color different letters differently without messing up positioning as long as each consonant is inside the same span as any any attached vowels / diacritics. You can also color the first letter (including its vowel) differently using the ::first-letter CSS selector.

Finally, you can use a layering approach as discussed in Jukka's answer when a consonant and its attached diacritics need to be colored differently. I have added a more thorough example to my code snippet.

I tried with SVGs to see if they offered a better solution. But SVG's suffer from the exact same problem.

PS Can you spot the deliberate spelling mistake in shalom? :D (AKA I cannot be bothered to fix it)

.example-one {
  font-size: 100px;
}
.example-one .one {
  color: red;
}
.example-one .two {
  color: green;
}
.example-one .three {
  color: pink;
}
.example-one .four {
  color: blue;
}

.example-two {
  font-size: 100px;
}
.example-two::first-letter {
  color: orange;
}

.example-three-a, .example-three-b {
  font-size: 100px;
  position: absolute;
  right: 0;
}

.example-three-a {
  color: red;
  z-index: 1;
}
.example-three-b {
  color: green;
}
<div class="example-one" dir="rtl">
<span class="one">שָׁ</span><span class="two">ל</span><span class="three">וּ</span><span class="four">ם</span>
</div>

<div class="example-two" dir="rtl">שָׁלוּם</div>

<div class="example-three-a" dir="rtl">שלום</div>
<div class="example-three-b" dir="rtl">שָׁלוּם</div>
like image 155
danday74 Avatar answered Sep 29 '22 11:09

danday74