Reputation: 68738
I had a web page template that was basically just:
<html>
<body>...</body>
</html>
But text in the body was (incorrectly) being interpreted as latin1 by my browser. So I changed it to:
<?xml encoding="utf-8"?>
<html>
<body>...</body>
</html>
This fixed the problem and the text was interpreted correctly as UTF-8 in my paticular browser (Chrome 17.x on Linux 3.x), however...
What is the best way (most current browser-compatible and forward-compatible) to specify that the text in a html page is encoded in UTF-8?
Upvotes: 0
Views: 4060
Reputation: 543
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
...
</head>
Upvotes: 7
Reputation: 100196
Don't put an <?xml?>
on non-xml. Use a meta
tag to specify the http content type charset.
Upvotes: 1
Reputation: 58667
I would think, this HTML4 way:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
... etc
Cut and pasted from a web page of mine.
Upvotes: 1