问题
I started learning HTML + CSS a week or two ago, and I'm facing a problem. I'm european so I need to use special characters like á, ã, ç , etc a lot. Is there any other way I can do that without using the corresponding code for each letter every time I need to use one? Like a code I can put in the beggining of the html document or something like that that would make all the special characters accepted.
回答1:
- Decide which encoding you want to use for your site; if you don't have any preference, use UTF-8.
- Save the .html file in that encoding in your text editor. Consult the help of your specific text editor how to choose which encoding the file gets saved in.
- Add
<meta charset="utf-8">to your<head>to instruct the browser to treat the page as UTF-8 encoded.- Preferably also configure your web server to output a
Content-Type: text/html; charset=utf-8HTTP header, since that takes precedence if present. Consult the manual of your web server how to do that.
- Preferably also configure your web server to output a
- Write literally any character you can input directly as is into your document and enjoy.
Further reading:
- https://www.w3.org/International/tutorials/tutorial-char-enc/
- Handling Unicode Front To Back In A Web App
- What Every Programmer Absolutely, Positively Needs To Know About Encodings And Character Sets To Work With Text
- UTF-8 all the way through
来源:https://stackoverflow.com/questions/35312259/using-european-characters-in-html