HTML Meta Charset vs HTTP Content-Type Header

Last updated: August 28, 2026.

The HTTP response header can declare an HTML document’s encoding before the browser reads the body. The meta charset element provides an in-document declaration. They should agree with the actual bytes.

Recommended setup

Send UTF-8 at both levels and put the meta declaration near the start of the head.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>UTF-8 page</title>
</head>
<body>...</body>
</html>
<?php
header('Content-Type: text/html; charset=UTF-8');
?><!doctype html>
<meta charset="utf-8">
<title>PHP response</title>

The HTTP declaration wins

When the header and meta element conflict, fix the server response instead of relying on the HTML declaration. Static files require web-server configuration; generated pages should set the header before any output.

Verify the network response

Inspect Content-Type in browser developer tools. Viewing page source confirms only the meta element. Also check that a framework, proxy, or template is not adding a second conflicting header.

Reference: MDN Content-Type header reference.

admin

admin