Early Access
content-type
Learn how to use the content-type meta tag to improve your site.
Defines the MIME type and character encoding for the HTML document. It sets the character set used for the HTML document, which is crucial for correctly displaying text.
Code Examples
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<meta http-equiv="content-type" content="" />
Recommendations
- Specify UTF-8 EncodingAlways set the character encoding to UTF-8 to avoid issues with the display of special characters and to ensure maximum compatibility across different browsers. UTF-8 is universally supported and is the best choice for internationalization.
- MIME Type SpecificationAlthough "text/html" is the default MIME type for HTML documents, explicitly defining the MIME type along with the character encoding is a good practice. It leaves no ambiguity for the browser to interpret the document type.
Related Documentation
Related Meta Tags
Content-Security-Policy
Defines which dynamic resources are allowed to load, thus helping to prevent cross-site scripting attacks, data injection, and other malicious attempts to exploit web page vulnerabilities.
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' https://apis.google.com;">
content-type
Defines the MIME type and character encoding for the HTML document. It sets the character set used for the HTML document, which is crucial for correctly displaying text.
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
default-style
Specifies the name of the preferred stylesheet to use on a web page. This allows users or user agents to choose the default stylesheet amongst many provided.
<meta http-equiv="default-style" content="Main Style">
refresh
Used to redirect the user to a new URL after a certain number of seconds, or to refresh the current page. While it can be useful for redirecting users or refreshing content, its usage is generally discouraged in favor of server-side redirects or JavaScript for a better user experience and performance.
<meta http-equiv="refresh" content="5;url=http://example.com">
X-UA-Compatible
Advises the web browser to display the webpage in compatibility view or a specific version of Internet Explorer. Primarily used to instruct Internet Explorer to use its Edge rendering engine.
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Community