Forum Moderators: open
<!DOCTYPE html>
...
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">It also identifies the type of file.
AddDefaultCharset utf-8W3C may give a warning (not an error) that the user may need the charset identifier if they download the file from your server, so if you allow downloading of your pages, then stick to the meta tag method.
AddLanguage en .html .htm .php
No, just somewhere in the HEAD.
Most people put TITLE and DESCRIPTION first,
then the other tags but it really doesn't matter.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">
<title>untitled document</title>
<link rel="stylesheet" href="screen.css" media="screen">
</head>
i normally define the charset before any markup that contains displayable characters.Same here. Obviously it only matters if your page title contains non-ASCII characters--and even then, only if you don't also have a Charset line in your config/htaccess. I guess it also makes a difference in the rare case where a document's stylesheet includes non-ASCII characters, most likely in "content:".
Here is the recommended order...:: further detour to look at the nearest random page ::
Darn, phranque, where do you find this stuff? ;) 1024 characters. Who knew?
META declarations should appear as early as possible in the HEAD element.
i normally define the charset before any markup that contains displayable characters.Most do, however it ends up at the bottom in the response header:
Date: Fri, 20 Jan 2017 02:04:56 GMT
Server: Apache
Accept-Ranges: bytes
Cache-Control: max-age=2592000, no-transform, public
p3p: CP="ALL DSP COR NID TAIa OUR NOR STA"
X-Robots-Tag: notranslate, noarchive
X-Frame-Options: deny
Content-Length: 26607
Keep-Alive: timeout=2, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
Content-Language: en
200 OK but it still ends up at the bottom of the response header.Does it matter? (Cue for phranque to locate yet another arcane information source.) A header, by definition, arrives before any of a page's visible (or even invisible) content.
I don't use a meta tag to set charset or language, I do it at the server levelDoes this work reliably if not all pages are the same language? The one drawback to setting a charset globally, as with an AddCharset declaration, is that it overrides anything set within the document itself. (This seems backward to me.) Now, it's not likely you'd use different charsets within the same site--especially if your default is UTF-8--but using different languages can be exceedingly common.
Does it matter?It would appear not.
I think you answered this pretty well.I don't use a meta tag to set charset or language, I do it at the server levelDoes this work reliably if not all pages are the same language?
Obviously it only matters if your page title contains non-ASCII characters--and even then, only if you don't also have a Charset line in your config/htaccess.
I don't use a meta tag to set charset or language, I do it at the server level, but it still ends up at the bottom of the response header.
A header, by definition, arrives before any of a page's visible (or even invisible) content.
Does this work reliably if not all pages are the same language?
since the document may be rendered in some cases without the server headers being provided it's better to also declare the character set in the documentYes, for many sites that allow proxies to serve their pages or if the site allows users to download the pages to their local machine, having the charset/language at document level is a must.