htmlcharacter-encodingdoctypew3c-validation

'charset=iso-8859-1' with <!DOCTYPE HTML> is throwing a warning


I just validated an HTML document using the W3C validator, and found that if I use:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

with:

<!DOCTYPE HTML>

However, it is fixed if I use:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

I don't really understand what is happening. Also, I don't even know how to use the DOCTYPE tag, I just copied and pasted one from around the web.


Solution

  • A couple of points:

    1. Any HTML5 validation should be taken with a grain of salt. The specification is still under active development, and not everything is set in stone.
    2. You're using the HTML4 syntax for that meta tag. Try <meta charset="iso-8859-1">

    That said, HTML validators don't serve that much purpose in this day and age.

    But apparently the default for HTML4 was iso=8869-1. That said, the default charset for HTML5 is UTF-8.

    More information about the HTML5 doctype can be found in this post by John Resig.