Okay, something just went crazy. Unless China is taking over starting with my test style.css file on my iepage - well I guess they are starting off on the right foot hating on IE, but anyways. It loads with no stylesheet - sad :( I go into the Web inspector and see that all my linked files are filled with [possibly] Chinese characters (瑨汭笠ऊ楷瑤...) I have tried deleting the files on the server and re-uploading them. The local files look fine and when loading the files directly they look fine. I didn't do anything that should of changed the rendering or anything either.
So I think I figured it out. This is weird. But anyway.
I copied and pasted your HTML to a local file to experiment with. And it loaded just fine. It was saved as UTF-8. Then I changed it to UTF-16, and I got exactly what you're seeing! As far as can tell, the browser (Firefox for Linux for me) is assuming the linked files are all in the same encoding as the HTML...
So - I assume the file on the server is in UTF-16, and if you change it to UTF-8 you should be good. Hope that fixes it!
PS: According to Firebug, your HTML is compressed by your server, even if you never explicitly told it to. But that doesn't seem to be causing any problems, thankfully.
I encountered this same problem with XML files exported from PowerShell that were embedded in iFrames.
There was no issue in IE10/11 or Edge, but Firefox and Chrome wouldn't load the stylesheet.
The original page loading the iFrames was UTF8 encoded, same with the stylesheet. However, the XML file was exported to UTF16LE ("Unicode" in PowerShell). When the XML file was loaded from the iFrame, it loaded the stylesheet as Chinese characters.
I converted the encoding in PowerShell...
Get-Content C:\foldername\file.html -Encoding Unicode | Set-Content -Encoding UTF8 C:\foldername\file.html
...and it worked! My guess is that IE must treat the encoding of all files the same as the parent, which meant that the UTF16LE encoded file was rendered as UTF8. Chrome and Firefox apparently don't do that.
Thanks Xavier Holt for setting me on the right path!
Another quick solution is to change the file encoding using Notepad.
Open the file in Notepad and Save As with the UTF-8 option selected from the drop down
it may be the .html file itself. I solved my similar problem by copying the contents of the original .html file and pasting it into a new file with the same name in the same directory (change the original's file name at first and delete the remainder of course)
Related
When I type my code in VSCode, it ends up looking like below in Google Chrome. Why would it be doing that?
I tried fixing my code and I expected it to come out looking cleaner in the browser. It actually just brought over all of the code.
When loading local files, browsers use the file extension to determine how to process the file.
Since your file doesn't have one, it treats it as plain text.
Rename it so it ends in .html.
From the URL, it is clear that you've not saved your file with .html extension. That is why it is showing up as text instead of a web page.
Save the file with name Mywebsite.html and try again. Hope this helps!
I have a file with HTML with UTF-16 LE encoding, the issue is CSS file is not linking to HTML
I copy all content in the HTML file to a new HTML file, it works fine.
After several attempts to understand the issue, I came to know the file is encoded with UTF-16 LE, but how encoding change the functionality and at the same time the file looks fine and it also rendering in chrome with all good characters.
My question is how encoding change the functionality?
I'm using Microsoft Windows 10 Home Single Language 64-bit Operating System on my laptop. I'm learning HTML on this laptop from W3Schools HTML Tutorial(The Best in Class Tutorial available on internet).
I wrote following HTML code into simple Notepad editor:
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
Then I named this file as index.html and was trying to save on my hard disk. While doing so I changed the option from Encoding drop-down box from ANSI to UTF-8 and then saved the file on my hard disk.
So my question without using the proper syntax for character encoding i.e.
<meta charset="UTF-8">
into <head> tag of HTML page will the character encoding get apply to the file index.html which I saved to my hard disk.
If yes how without adding a code for it? If no why even after setting the encoding type before saving the file?
The character encoding of the file itself only has to do with how the content of the file is saved. Special characters etc. How the file is viewed is a completely different matter. Depending on the server, the file will either base its encoding on the server-side setup (httpd.conf, for instance), or if it's served via PHP, what settings are set up in php.ini. If the server, for some reason, does not use any of those settings, the <meta>-tag in the HTML might be used, and then it should match the method it's saved with, since if not, characters might be shown either broken, wrong, or just like gibberish.
Browsers (Chrome and Safari) Try to download this html file when opened. It is only on that link that it tries to download it. Also note that internet explorer opens it without a problem.
The one thing that I think is causing this may be wordpress or some plugin within wordpress but it seems unlikely since no wordpress is used in that page.
Contact html code
Likely an incorrect mime type in your .htaccess file. I suggest going into it and looking for any unwanted lines similar to the below and removing them.
AddHandler application/ etc.
and also ensure your type is set as follows:
AddType text/html .html
In order to open .htaccess in cPanel:
Click File Manager and make sure to tick Show Hidden Files (dotfiles) before clicking Go. Then the .htaccess should show up the location where wp (wp-admin, wp-content, wp-includes) is installed.
One possible cause is that there is a problem with your server configuration that is giving the visiting browser the wrong mime type.
The correct mime type for html is: text/html
The mime type that your server is sending is: application/x-httpd-php
You appear to be running Apache. As a result there are two possible files that could be causing this, either in .htaccess or in one of Apaches configuration files.
Try adding the text below to a .htaccess file in your directory, or look for a mention of application/x-httpd-php
AddType text/html .html
I had to add the following at it worked:
AddHandler application/x-httpd-php .php
I've had this issue a couple of times. The problem for me was the web server was automatically handling PHP requests outside of the .htaccess file. For some reason, changing settings in WordPress would sometimes cause a change in the .htaccess file, adding a handler for PHP. This would cause the server to burp at every PHP request thereafter and attempt to serve the file instead of handle it.
The solution, then, was to manually remove the handler that was automatically added to the .htaccess file (and leave a comment for myself so I wouldn't pull my hair out every time!)
Had same thing happen to me. I know this sounds funny but check to make sure none of the keys on your keyboard are stuck. i.e) ALT key , etc. if not. Try hooking up a new keyboard and then browse.
I spent the last few hours getting my website to validate HTML 4.01 Strict and I actually have succeeded in that, but there is still one warning which I can't get rid of. The warning is:
Character Encoding mismatch!
The character encoding specified in
the HTTP header (iso-8859-1) is
different from the value in the
element (utf-8). I will use the value
from the HTTP header (iso-8859-1) for
this validation.
The page in question is www.dubiousarray.net/default.html. As you can see from the page source I have the following meta element:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
and I have made sure that the default.html file is saved with UTF-8 encoding. The strange thing is all the other pages in the site validate without this warning and they have the same meta tag and were saved in exactly the same way. I am pretty sure it is something to do with the server configuration. The .htaccess file looks like this at the moment:
# Use PHP 5 as default
AddHandler application/x-httpd-php5 .php
AddDefaultCharset UTF-8
But I have tried all the fixes shown on this page and none of them worked. How can I go about getting rid of this warning?
In Firefox, if you right click on the page and select 'View Page Info', default.html shows as ISO-8859-1, while all the other pages show UTF-8.
All the html file have been created and saved in the exact same way (character encoding set to UTF-8 without BOM), but default.html is the only one which isn't displaying as UTF-8. So I assume the server is doing something special to the default.html file though I am not sure what as there is not sign of it in the .htaccess file.
You need to replace the HTTP-level header.
This should work:
<?php
header('Content-type: text/html; charset=utf-8');
?>
Note that the above must be the first thing in your file. No exceptions. See header.
For general information on how to change the character set header in different web stacks, see Setting the HTTP charset parameter.
The server is clearly marking the document as ISO-8859-1 in the HTTP headers. Try saving default.html using UTF-8 encoding with a proper editor.
Include this in your code:
<meta charset="utf-8" />
Okay, I have come up with a partial solution to my problem. As it was only the default.html file which was causing the warning I assumed that the server was doing something special to it because of its name. So I made a new file called home.html with the same contents as the default.html file and pointed the .htaccess file to the new file (see line 3 below).
# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
DirectoryIndex home.html
AddDefaultCharset UTF-8
This fixed the problem and all files are now recognised as UTF-8. I'm still not sure what the server was doing to the default.html file or where the settings concerning that are, but as my problem is gone I will forget about that.
Remove AddDefaultCharset from .htaccess and check the encoding.
I saved the HTML source of your webpage and opened it. Encoding was detected as UTF-8. However, on viewing the same webpage served by your web server, the encoding is ISO-8859-1. That is why I suggest removal of the former redundant rule.