How can I set charset in HTML? [duplicate] - html

This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 6 years ago.
I'm having a trouble with a site. I set the charset to Unicode, but it still won't work. Here there is sample code of how I set it:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
http://www.w3.org/TR/html4/loose.dtd>
<html lang="it">
<head>
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge" charset="iso-8859-1">
<title>HOME</title>
</head>
<body>
<h1> This are some accented letters and various symbol</h1>
<p>è é ç ò ù § ▼ à </p>
</body>
</html>
[1]: https://i.stack.imgur.com/csRk2.jpg

Add the following line within the head tag and remove your charset:
<meta charset="UTF-8">
Or replace
<meta http-equiv="X-UA-Compatible" content="IE=edge" charset="iso-8859-1">
with
<meta http-equiv="X-UA-Compatible" content="IE=edge" charset="utf-8">
For more information, check HTML <meta> charset Attribute

Related

black diamond question marks- Rmarkdown

I have two rmarkdown generate html reports.
The first one (rmarkdown version 1.10, pandoc version 2.7.1)with R is working fine
The second one (rmarkdown version 2.2, pandoc version 2.7.1) had black diamond with questions marks show up in places with html characters.
I compared the two documents, and it seems that the only differences are in the headings of the html document.
In the first document, the heading is as following
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
In the second document, the heading is as following
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
I am opening both with Chrome. Can someone help explain why this might be happending?
Thank you!

<!DOCTYPE html> vs <!doctype html> and <meta charset="utf-8"> vs <meta charset="utf-8" />

Document Type Declaration
<!DOCTYPE html> vs <!doctype html>
Capital letter DOCTYPE declaration or small letter doctype declaration which one is authentic?
Character encoding meta tag
Same type of 3 character encoding meta tags
<meta charset="utf-8"> non-slash version
<meta charset="utf-8"/> slash version
<meta charset="utf-8" /> a single white space followed by slash.
Which one is authentic?
To be sincere all are the same.
It depends on your preference
You can choose to use any of them.

<meta charset="utf-8"> still needed today?

I look at the bootstrap4 introduction and see this:
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
Source: https://getbootstrap.com/docs/4.4/getting-started/introduction/
Is <meta charset="utf-8"> still needed today?
I only support browsers with a market share greater than 2%.
it's not necessary but it doesn't hurt to add an single line to your code.

On the web page, place a link to the txt file and specify the encoding of the file as utf-8

Now the code is:
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<span lang="en-us">txt - </span>
How to insert charset="utf-8" attribute?
You should declare the whole document as UTF-8 with a charset command.
Add this between <head> and </head>:
<meta charset="utf-8"/>

charset=utf-8 - but it cannot display "ü"

I declared the charset like all current HTML5 websites, but now German letters cannot be displayed anymore. If I leave the declaration out it works again. I think one should have that declaration. What is wrong?
HTML
<!DOCTYPE html>
<html lang="de">
<head>
<meta http-equiv="content-type" content="text/html,charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>äää</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
üüü ääää öööö
</body>
</html>
I believe that the charset parameter needs to be separated from the MIME type by a semicolon, not a comma. See the W3 docs.
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
you have insert , instead of ; between charset and text/html
try this:
<meta http-equiv="content-type" content="text/html; charset=utf-8">
Check that your html file is saved in UTF-8 and if you use HTML5 declaration your meta can look like:
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
.
.
.
</head>