I've following HTML5 document :
<!DOCTYPE html>
<html>
<head> </head>
<body>
<p>Beträge: 20€</p>
</body>
</html>
The output of above cod is as below :
Beträge: 20€
The I tried below HTML5 code :
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<p>Beträge: 20€</p>
</body>
</html>
The above code gave me the following output as I was expecting :
Beträge: 20€
As per my knowledge, the default character encoding for HTML5 is UTF-8. It's default means it should not be specified explicitly inside <meta>
tag.
So, in my first code snippet I skipped the code <meta charset="UTF-8">
But I got some weird unexpected result.
Then, I tried by adding the code <meta charset="UTF-8">
in between <head>
pair of tags and it worked perfectly fine and I got the expected result.
So, my question is since the default character encoding in HTML5 has been set to UTF-8 why it's not working if it's not been specified explicitly?
Why there is a need to specify the character encoding "UTF-8" in an HTML5 document?