How to set a charset header for a html page? - html

Even though i use the below meta tag to set the content-type and charset, i am not seeing the charset header in the firefox firebug debugger.
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
Any help is appericiated.

The meta tag does not affect the HTTP headers sent. (Long ago, it was kind-of meant to do such things, but apart some forgotten experiments, it never did.) It specifies the encoding to be implied if HTTP headers do not specify the encoding; so it’s really not equivalent to an HTTP header (as the name ´http-equiv` suggests) but a replacement, surrogate, Ersatz for an HTTP header.
The way to set the HTTP headers depends on the server software and its settings.
But if the headers do not specify the encoding, then the meta tag takes effect. You ca check via the View → Encoding menu in Firefox which encoding is being applied.

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
It is how you set charset header for HTML files,there is nothing wrong.
Why would you use firebug to check the Charset? Just right click your mouse key and from the context menu select view page info and it will give you the page charset.

Related

Setting two charsets? utf-8 and text/html

I'm new to learning HTML and learning about metadata in a webpage. It seems like people prefer you have to set the character set to support utf-8 and people are also saying have charset="text/html" so browsers know what kind of information they are receiving. How can I set both since it seems like both use the same attribute?
text/html is a media type, not a character set. The server can send a Content-Type: text/html; charset=utf-8 header to identify the content as HTML encoded as UTF-8. When you’re using a <meta> tag, though, the content is already known to be HTML and the only thing that matters is the charset, so HTML5 introduced the option to write <meta charset="utf-8"> as shorthand for <meta http-equiv="Content-Type" content="text/html; charset=utf-8">. (Older browsers also support this because people had a habit of forgetting quotes in the original.)
In short, if you’re using a <meta> tag, just write this:
<meta charset="utf-8">
and you’re done. The page is already HTML.

Meta tags and language

I have a website writteng in greek.
<meta name="keywords" content="" /> can I use greek language in content or just in english?
If I can write them using greek chars, do I have to add anything to meta tag?
Thank you
You can use any character you want from the character set you are using. Just make sure that your web server send the correct character set headers in the HTTP request. You may also add a <meta> element specifying the charset, but it's not strictly necessary.
I use UTF-8 in these examples as I think it's a code charset and prefer to use it myself. It's on its way to take over as the standard charset on the web.
HTTP header which should be sent by the web server:
Content-Type: text/html; charset=utf-8
Optional <meta> element for your document:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

Browser does not follow the page charset

I defined a webpage to use iso-8859-1 like the following:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
But when I open the page in the browser, the browser is using UTF-8 to read the page. Why the browsers does not following the page charset?
If you have access to your apache config, you should look in the httpd.conf (or equivalent) for the following directive:
AddDefaultCharset UTF-8
According to apache docs, this will override the meta declaration that you set. http://httpd.apache.org/docs/2.0/mod/core.html#adddefaultcharset
You could turn it off by replacing the directive with this:
AddDefaultCharset Off
The information that really matters is the real Content-Type HTTP header sent by the web server. You can inspect it with Firebug of a similar tool. <meta> tags should only matter if you save the file to disk and the HTTP header is lost.

Webview doesnt show Æ Ø Å properly

I have some content on a webpage which contains æ ø å, but my webview cant show them properly.
Does anyone know what the problem might be ?
In order to use UTF-8 characters inside an (X)HTML page you declare the encoding with this meta tag (in the head section of the page):
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
If that alone does not work you may be able to find more useful information here.
You need to ensure that the HTML file is saved as UTF-8 and that the Content-Type header in the HTTP response contains the proper charset. You can verify the headers by among others Firebug.
A <meta> tag for Content-Type would only work when the Content-Type header in the response is absent and this is usually not the case when the HTML file is served over HTTP. However, its presence is good for offline viewing and self-documentary purposes.

latin characters showing in some parts of the page and not others

the page in question is Apple Amor
You can see that in the footer the spanish vowels seem to be showing properly , but in the slide down bar(header) they get messed up.
Any ideas why ?
Your page is encoded in ISO-8859-1. Wherever that header comes from, it is most likely encoded in UTF-8.
You would have to change the character set of your page to UTF-8 (that would probably have some consequences) or convert the incoming data from the header. I don't know where it's coming from, so it's hard to tell what the right method would be.
Mandatory basic reading on the issue: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
Your page source shows that you're using:
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
Note that the above tag is not well formed. Where is its closing character "/"? Content-Type should be between double quotes.
Add this tag to your page and test:
<html lang="es">
If that doesn't solve your problem try to change the charset tag to:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />