top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What's new HTML 5 DocType and Charset?

+6 votes
776 views
What's new HTML 5 DocType and Charset?
posted Sep 9, 2015 by Sathyasree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

Both forms of the meta charset declaration are equivalent and should work the same across browsers. But, there are a few things you need to remember when declaring your web files character-set as UTF-8:

  1. Save your file(s) in UTF-8 encoding without the byte-order mark (BOM).
  2. Declare the encoding in your HTML files using meta charset (like above).
  3. Your web server must serve your files, declaring the UTF-8 encoding in the Content-Type HTTP header.

Apache servers are configured to serve files in ISO-8859-1 by default, so you need to add the following line to your .htaccess file:

AddDefaultCharset UTF-8

This will configure Apache to serve your files declaring UTF-8 encoding in the Content-Type response header, but your files must be saved in UTF-8 (without BOM) to begin with.

Notepad cannot save your files in UTF-8 without the BOM. A free editor that can is Notepad++. On the program menu bar, select "Encoding > Encode in UTF-8 without BOM". You can also open files and re-save them in UTF-8 using "Encoding > Convert to UTF-8 without BOM".

answer Sep 10, 2015 by Vrije Mani Upadhyay
+1 vote

Since HTML 5 is now not a subset of SGML, its DocType is simplified as follows:

<!doctype html>
And HTML 5 uses UTF-8 encoding as follows:
<meta charset="UTF-8">
answer Sep 10, 2015 by Shivaranjini
...