Question:
When putting HTML into a validator, I got a weird warning message about UTF-8? (read description for details)?
shawna.mckay.1
2016-11-30 20:50:39 UTC
I'm working on an assignment due tomorrow. The assignment was to grab a website template from the internet and use that to create a fake company website.
Then we had to put our website through a validator.

I put the website through the validator before I did any editing to it and I got a warning error that says:

"Warning: Legacy encoding windows-1252 used. Documents should use UTF-8."

The piece of code it was reffering to was:

""

The placement is:

"



Your Company Name

"


Can someone explain to me what this error message is and how to fix it? Thank you!
Three answers:
Me2
2016-12-01 01:49:53 UTC
Since you're using HTML5, you may replace with .  You may use instead, but be sure to save the file using UTF-8 encoding (not as Unicode) if it contains characters beyond the 8-bit range.



Regardless of the OS they run under, all modern web browsers render windows-1252 characters properly, as it's required by HTML5.  UTF-8 is not a character set at all, but rather a method of encoding both single-byte characters and multi-byte Unicode.  Note that the first 256 Unicode characters is actually the windows-1252 character set.



HTML5 does not require UTF-8 encoding, and about one out of five web pages do not use it.  HTML5 requires only that the declared encoding be ASCII-compatible and at least 8 bits.  The warning that "Documents should use UTF-8" is simply heavy-handed, since there's no compelling reason to declare UTF-8 encoding for plain ASCII text.



Chris said, "if you use characters like ä or é, people might see questionmarks instead."  As is happens, ä and é are part of windows-1252 (codes 228 and 233) and would be properly displayed.



(I note that you closed the .  That method is required in XHTML and XML, not HTML.  W3C provides this example in HTML5

   

See the longer code example under https://www.w3.org/TR/html5/document-metadata.html#the-head-element

)
efflandt
2016-11-30 21:22:15 UTC
Apparently the web page was created by someone using a Windows program. But hint, not everybody runs Windows. Some people run Mac. I happen to be running Linux, although, I do have Microsoft True-Type fonts.

https://en.wikipedia.org/wiki/Windows-1252



UTF-8 is a more common universal character set than windows-1252.

https://en.wikipedia.org/wiki/UTF-8
Chris
2016-12-01 03:09:35 UTC
It basically means if you use characters like ä or é, people might see questionmarks instead.



If you want to fix this, get Notepad++, open your document, then select "Encoding -> Convert to UTF8" from the menu. Then replace







with







and save.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...