Search code examples
htmlmeta-tagshtmlspecialchars

Html special characters not being shown in browser despite UTF-8 meta tag applied to html file


I am using jquery method to load html file in a div content as like

<script type="text/javascript" language="javascript" >
$(function () {
    $("#divWelcomePage").load("welcome.html");
});

Now, The issue is I got the html file content over there but am not getting the value of special characters like (apostrophe('),double quotes("") in the div.

Then I put a tag like

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

and Now,it works for some html pages but for some other pages I still don't get any value. Instead I get � character:(

Please suggest some really reliable way for me to do so. I have also studied that using html editor to convert these html files to support UTF characters can make this html file work But still it is not working as I have tried to use a few html editor like Sublime Text 2. Please suggest me some good html editor too if you still believe using those editors will help my case..


Solution

  • You need to include a valid doctype for html entities to display correctly.

    Try adding this to your welcome.html page

    <!DOCTYPE html>