<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ZakhrafAsmaHub</title>
    <description>The latest articles on DEV Community by ZakhrafAsmaHub (@umar_arain_056e3b4514883c).</description>
    <link>https://dev.to/umar_arain_056e3b4514883c</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4245732%2F532098f6-6d3b-4f3e-b82d-17032e60c496.png</url>
      <title>DEV Community: ZakhrafAsmaHub</title>
      <link>https://dev.to/umar_arain_056e3b4514883c</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/umar_arain_056e3b4514883c"/>
    <language>en</language>
    <item>
      <title>How to Handle Arabic Unicode Text in HTML and CSS</title>
      <dc:creator>ZakhrafAsmaHub</dc:creator>
      <pubDate>Sun, 15 Nov 2026 10:10:55 +0000</pubDate>
      <link>https://dev.to/umar_arain_056e3b4514883c/how-to-handle-arabic-unicode-text-in-html-and-css-2o49</link>
      <guid>https://dev.to/umar_arain_056e3b4514883c/how-to-handle-arabic-unicode-text-in-html-and-css-2o49</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Arabic text can be challenging to display correctly on websites, especially when it contains decorative symbols, diacritics, or a mixture of Arabic and English characters.&lt;/p&gt;

&lt;p&gt;Fortunately, HTML, CSS, and Unicode provide the tools developers need to handle Arabic typography properly.&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll explore practical examples of displaying Arabic text, managing right-to-left layouts, and avoiding common Unicode mistakes.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Understanding Arabic Unicode
&lt;/h2&gt;

&lt;p&gt;Unicode assigns code points to characters from writing systems around the world.&lt;/p&gt;

&lt;p&gt;Some Arabic examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ا — U+0627 (Arabic Letter Alef)&lt;/li&gt;
&lt;li&gt;ب — U+0628 (Arabic Letter Beh)&lt;/li&gt;
&lt;li&gt;م — U+0645 (Arabic Letter Meem)&lt;/li&gt;
&lt;li&gt;َ — U+064E (Arabic Fatha)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unicode characters are not images. They are text that browsers render using available fonts.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Setting Up HTML for Arabic
&lt;/h2&gt;

&lt;p&gt;Start with a basic HTML document:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"ar"&lt;/span&gt; &lt;span class="na"&gt;dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"rtl"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Arabic Text Example&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;مرحبا بالعالم&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;هذا مثال على نص عربي.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three important settings are used here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;charset="UTF-8"&lt;/code&gt; enables proper interpretation of Unicode text.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lang="ar"&lt;/code&gt; identifies the document language.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dir="rtl"&lt;/code&gt; specifies right-to-left text direction.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without correct direction settings, mixed-language content may appear confusing.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Styling Arabic Text With CSS
&lt;/h2&gt;

&lt;p&gt;Arabic typography benefits from readable fonts and comfortable line spacing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.arabic-content&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Noto Naskh Arabic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Tahoma&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.9&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rtl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example provides a font fallback and allows the text to follow its natural reading direction.&lt;/p&gt;

&lt;p&gt;Remember that a font must actually be available or loaded for the browser to use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Mixing Arabic and English Text
&lt;/h2&gt;

&lt;p&gt;Mixing left-to-right and right-to-left languages can cause punctuation and numbers to appear in unexpected positions.&lt;/p&gt;

&lt;p&gt;HTML provides the &lt;code&gt;&amp;lt;bdi&amp;gt;&lt;/code&gt; element to isolate text whose direction may differ from surrounding content.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
  Username: &lt;span class="nt"&gt;&amp;lt;bdi&amp;gt;&lt;/span&gt;محمد ★&lt;span class="nt"&gt;&amp;lt;/bdi&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;&amp;lt;bdi&amp;gt;&lt;/code&gt; element is particularly useful when displaying user-generated names.&lt;/p&gt;

&lt;p&gt;Developers can also use &lt;code&gt;dir="auto"&lt;/code&gt; when the direction of text is unknown.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Working With Decorative Arabic Symbols
&lt;/h2&gt;

&lt;p&gt;Arabic names can be decorated using Unicode characters.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;p&gt;Normal text:&lt;/p&gt;

&lt;p&gt;محمد&lt;/p&gt;

&lt;p&gt;Decorated text:&lt;/p&gt;

&lt;p&gt;★ محمد ★&lt;/p&gt;

&lt;p&gt;『محمد』&lt;/p&gt;

&lt;p&gt;مُحَمَّد&lt;/p&gt;

&lt;p&gt;These examples combine ordinary Arabic letters with symbols or diacritics.&lt;/p&gt;

&lt;p&gt;Developers should remember that visual appearance depends on font support and platform compatibility.&lt;/p&gt;

&lt;p&gt;If you want to experiment with copy-ready examples, the &lt;a href="https://zakhrafasmahub.com/arabic-decoration/" rel="noopener noreferrer"&gt;ZakhrafAsmaHub Arabic Decoration Tool&lt;/a&gt; provides Arabic text decoration options that can be tested in different applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Handling Invisible Unicode Characters
&lt;/h2&gt;

&lt;p&gt;Some Unicode characters are not visibly rendered.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;U+200B — Zero Width Space&lt;/li&gt;
&lt;li&gt;U+200C — Zero Width Non-Joiner&lt;/li&gt;
&lt;li&gt;U+200D — Zero Width Joiner&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These characters serve different text-processing purposes.&lt;/p&gt;

&lt;p&gt;For example, the Zero Width Non-Joiner can prevent joining between characters in certain writing systems.&lt;/p&gt;

&lt;p&gt;However, inserting invisible characters unnecessarily may create accessibility and debugging&lt;/p&gt;

&lt;h2&gt;
  
  
  7. JavaScript Unicode Example
&lt;/h2&gt;

&lt;p&gt;JavaScript supports Unicode strings directly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;arabicName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"محمد"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arabicName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arabicName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The spread operator counts Unicode code points, but not necessarily user-perceived characters.&lt;/p&gt;

&lt;p&gt;For more accurate character segmentation, developers can use &lt;code&gt;Intl.Segmenter&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Common Mistakes to Avoid
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Incorrect encoding:&lt;/strong&gt; Always use UTF-8.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Missing RTL direction:&lt;/strong&gt; Use &lt;code&gt;dir="rtl"&lt;/code&gt; for Arabic content.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unsupported symbols:&lt;/strong&gt; Test decorative text across platforms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Excessive invisible characters:&lt;/strong&gt; Avoid unnecessary characters that may cause display issues.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Poor accessibility:&lt;/strong&gt; Keep Arabic text readable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Unicode plays an important role in modern Arabic websites.&lt;/p&gt;

&lt;p&gt;By using UTF-8, proper text direction, readable fonts, and careful character handling, developers can build reliable multilingual experiences.&lt;/p&gt;

&lt;p&gt;Always test Arabic text across browsers and devices before publishing.&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
      <category>unicode</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
