Support

Find answers, guides, and tutorials to supercharge your content delivery.

Avoid a Character Set in the Meta Tag

Updated on October 4, 2018
Avoid a Character Set in the Meta Tag

What is a character set?

A character set (charset) is a predefined list of characters each defined by a number. Browsers make use of character sets in order to determine what should be displayed on a web page. Depending on which charset is defined by the website will determine how browsers will display the site to your visitors. There exists multiple charsets, currently the most popular being UTF-8. A few other examples of charsets include:

  • ASCII: Uses a unique binary 7-bits number to define every upper and lowercase letter in the alphabet, numbers from 0-9, and some special characters.
  • ISO-8859: An extension upon ASCII to include international characters.
  • ANSI: Default charset in Windows up to Windows 95.

The default charset currently being used in HTML5 is UTF-8 which solves many character encoding problems that were prevalent with previous character sets. To learn more about charsets and the differences that exists between a few of them, read the TML Encoding article.

What is a meta tag?

A meta tag is an HTML tag which provides information pertaining to a particular web page. This tag type resides within the head of an html document. An example of a meta tag may resemble the following snippet.

<head>
    <title>Site title</title>
    <meta name="description" content="Description of this page">
    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
</head>

In the above example, two meta tags are defined.

  • The first meta tag contains the description information of the page. This is what Google will display in the SERPs if you have defined it.
  • The second meta tag defines which charset the browser should use when accessing this page.

However, according to best practice, you should avoid a character set in the meta tag in order to improve loading times and avoid information duplication. Additionally, if your users are using Internet Explorer 8 to browse your website, specifying a character set in the meta tag disables the use of the lookahead downloader. Consequently this incompatibility issue causes increased loading times for users.

How to avoid a character set in the meta tag?

To avoid a character set in the meta tag is a recommendation given by many site speed test tools. There are a few options available to defining a charset without using a meta tag. Depending on your server side language or web server you can define the character set so that it will be displayed within the HTTP response header.

This is the desired method for defining a charset. The following provides snippets on how to set a charset using PHP, Apache, or Nginx.

PHP

If you are using PHP code and want to include the charset header, simply add the following snippet to the top of your PHP file.

header("Content-Type: text/html; charset=utf-8");

Apache

For Apache web servers, adding the following directive to your .htaccess file will enable the charset HTTP response header.

AddType 'text/html; charset=UTF-8' html

Nginx

For Nginx users, the following snippet can be added to your config file.

http {
    include /etc/nginx/mime.types;
    charset UTF-8;
    ...
}

When looking to further optimize your site and are provided with the recommendation to avoid a character set in the meta tag, simply removing the tag and implementing one of the above solutions is an easy way to solve the issue. Doing this will help further increase your page load time as well as avoid any information duplication that may cause browser confusion.

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

Get started
KeyCDN uses cookies to make its website easier to use. Learn more