Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />?

When I create a new Html file in Visual Studio 2017, this:

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

always shows up in the <head>.

The program works just fine without it. So, can someone please tell me what it does?

like image 620
SKero2004 Avatar asked Mar 06 '23 22:03

SKero2004


1 Answers

According to HTML Dog:

The charset attribute can be used as a shorthand method to define an HTML document's character set, which is always a good thing to do. <meta charset="utf-8"> is the same as <meta http-equiv="content-type" content="text/html; charset=utf-8">.

So it's basically used to define the charset of your HTML document.

The reason why Visual Studio 2017 adds both the meta tags may be because this way your HTML will be maximum compatible with older browsers.

<meta http-equiv="content-type" content="text/html; charset=utf-8"> is the old way to define the charset.

<meta charset="utf-8"> is the new and shorter way to do the same thing.

like image 58
Inus Saha Avatar answered May 20 '23 02:05

Inus Saha