Reputation: 73928
I use Asp.net In my document I use:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
I would like to know if is necessary to add also this MetaTag:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Thanks for your tme on this.
Upvotes: 0
Views: 304
Reputation: 5505
Doctype Definition
The doctype declaration should be the very first thing in an HTML document, before the
<html>
tag.The doctype declaration is not an HTML tag; it is an instruction to the web browser about what version of the markup language the page is written in.
The doctype declaration refers to a Document Type Definition (DTD). The DTD specifies the rules for the markup language, so that the browsers render the content correctly.
See the reference:
http://www.w3.org/QA/Tips/Doctype
http://www.w3.org/TR/html4/struct/global.html
Character Encoding
The document character set for XML and HTML 4.0 is Unicode (aka ISO 10646). This means that HTML browsers and XML processors should behave as if they used Unicode internally. But it doesn't mean that documents have to be transmitted in Unicode. As long as client and server agree on the encoding, they can use any encoding that can be converted to Unicode. Read more about the document character set.
It is very important that the character encoding of any XML or (X)HTML document is clearly labeled, so that clients can easily map these encodings to Unicode. This can be done in the following ways...
See The Reference http://www.w3.org/International/O-charset
Both are necessary, but not dependent to each other.
Upvotes: 1
Reputation: 499062
You should add the meta tag, though it is not compulsory.
The DOCTYPE
doesn't not automatically tell you what the character set is, so you should add the information that the file is encoded as UTF-8
.
You should also ensure the content-type
HTTP header is also set to UTF-8
.
Upvotes: 2
Reputation: 229
Yes this is perfectly fine to add that just make sure the file extension has .aspx or whatever attached to it.
Example ASP page with html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<body bgcolor="black">
<center>
<h2>Hello There!</h2>
<p><%Response.Write(now())%></p>
</center>
</body>
</html>
Hope this helps.
Upvotes: 0