Wednesday, March 9, 2022

[FIXED] HTML not supporting arabic language

Issue

I am working on a project which i need to convert it in Arabic. i am using codeigniter. when I write the Arabic in html it show me that (?????) for Arabic.

This is my HTML code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title></title>
<meta name="" content="">
</head>
<body>
<h1 dir='rtl'
lang='ar'>checking</h1>
<p dir="rtl" lang="ar" style="color:#e0e0e0;font-size:20px;">رَبٍّ زِدْنٍي عِلمًا</p>
</body>
</html>

it shows me text like that:
enter image description here


Solution

As i can see you are using some html5 based attributes like dir so you need to convert the html4 document to html5 doctype and use lang attribute on html tag and meta tag:

<!DOCTYPE HTML>
<html lang="ar">
    <head>
       <meta charset="utf-8">

A sample demo is below:

<h1 dir='rtl' lang='ar'>checking</h1>
<p dir="rtl" lang="ar" style="color:#e0e0e0;font-size:20px;">رَبٍّ زِدْنٍي عِلمًا</p>

the view source of this snippet looks something like this:

enter image description here




Answered By - Jai

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.