HowToDoInJava

  • Python
  • Java
  • Spring Boot
  • Dark Mode
Home / HTML5 / HTML5 Charset – Character Encoding Declaration

HTML5 Charset – Character Encoding Declaration

Today, web host applications for different geographies and languages and different languages use different character sets, or charsets. To inform the browser about character set used in HTML5 document, you need to use the meta tag with attribute name charset.

Let’s see an example of charset declaration of UTF-8.

<meta charset = "UTF-8" />
I would recommend using UTF-8 wherever possible, since it can represent any character in almost 99.99% cases. It is also well supported by most of the modern browsers.

If you want to provide the charset information using old manner, then you will use below format. It’s given here for information purpose, and is not recommended.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 

XHTML documents have a third option: to express the character encoding via XML declaration:

<?xml version="1.0" encoding="UTF-8"?>
  1. While UTF-8 will work in most instances, a lot of developers have found that using ISO-8859-1 as the charset gives even more flexibility.
  2. Another charset, UTF-16, sometimes results in wrong characters and, in some cases, applications operating improperly.
  3. Most modern web browsers feature automatic character encoding detection – if not declared explicitely.

Happy Learning !!

References:
https://www.w3.org/International/articles/http-charset/index
https://en.wikipedia.org/wiki/Character_encodings_in_HTML

Was this post helpful?

Let us know if you liked the post. That’s the only way we can improve.
TwitterFacebookLinkedInRedditPocket

About Lokesh Gupta

A family guy with fun loving nature. Love computers, programming and solving everyday problems. Find me on Facebook and Twitter.

Comments are closed on this article!

Search Tutorials

Meta Links

  • About Me
  • Contact Us
  • Privacy policy
  • Advertise
  • Guest and Sponsored Posts

Recommended Reading

  • 10 Life Lessons
  • Secure Hash Algorithms
  • How Web Servers work?
  • How Java I/O Works Internally?
  • Best Way to Learn Java
  • Java Best Practices Guide
  • Microservices Tutorial
  • REST API Tutorial
  • How to Start New Blog

Copyright © 2020 · HowToDoInjava.com · All Rights Reserved. | Sitemap

  • Sealed Classes and Interfaces