0

My HTML code:

<!DOCTYPE html>
<html lang="en">
  <head>
    <!--<meta charset="UTF-8">--> 
  </head>
  <body>
    <h1>আমার নাম ফারহান</h1>
  </body>
</html>

Output

Even though I commented out <meta charset="UTF-8"> I can still write in Bangla. How is this possible?

truth313
  • 21
  • 5
  • The content of a text file has no influence on the charset/encoding used to write it to disk. You can write "This is UTF-8 encoded" to a file even if it is not UTF-8. Most text editors or IDEs allow you to change the encoding used to write a file. – lupz Aug 30 '22 at 07:51
  • @lupz Why do we even bother writing `` then? What purpose does it serve if we can use any character we want without utf-8? – truth313 Aug 30 '22 at 10:07
  • I struggle to find a definitive reference for this, but I think UTF-8 is the one and only valid encoding for HTML5 documents (See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-charset). Still, this is a question of how this is handled by the browsers but I think this meta tag is an interpretation hint for older browsers. I suggest to use UTF-8 anywhere (unless there are valid reasons for using another encoding) and keep that line in your HTML documents. I like this article on encodings: https://kunststube.net/encoding/ – lupz Aug 30 '22 at 12:39

0 Answers0