3

Some background first:

2003 - 2010

In 2003, I switched from HTML 4.01 to XHTML 1.0 and encoded my XHTML documents, using:

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

2010 - 2013

In 2010, I switched from XHTML 1.0 to HTML5, but, because the text-editor I was using at the time did not allow me to save text documents in UTF-8, I continued using ISO-8859-1.

The usefulness of saving documents in UTF-8 only became more apparent to me in early 2013, when I started working on a project about Iceland, involving frequent use of the characters:

  • æ / Æ (ash)
  • ð / Ð (eth)
  • þ / Þ (thorn)

and many accented vowels (á, é, í, ó, ú, ý).


2013 - Present

So in 2013 I found a new text editor which enabled me to save documents using UTF-8 encoding and I started using:

<meta charset="utf-8">

Here's the key point:

Throughout 2003-10 and 2010-13, on the rare occasion whenever I needed to display an extended Latin character like (â, é or ü), I always used the standard HTML escapes (or HTML entities) like:

  • &acirc;
  • &eacute;
  • &uuml;

Since that was already a habit, after I finished my Icelandic project in 2013, whenever I was writing, saving, editing and uploading UTF-8 encoded HTML5 documents, I carried on using:

  • &szlig;, &auml;, &ouml; etc. if I was writing something in German;
  • &ntilde;, &aacute;, &oacute; etc. if I was writing something in Spanish;
  • &ccedil;, &egrave;, &ocirc; etc. if I was writing something in French

etc.


In my head, I had the idea that it was both safer and better to use an HTML Entity wherever possible. (Perhaps that came from already knowing that it's always better to mark up &amp; rather than & and certainly safer to mark up &#39; rather than ').

But I've recently come across the following assertions:

It is almost always preferable to use an encoding that allows you to represent characters in their normal form, rather than using named character references or numeric character references.

Source: When Not To Use Escapes by W3

Unnecessary use of HTML character references may significantly reduce HTML readability. If the character encoding for a web page is chosen appropriately, then HTML character references are usually only required for markup delimiting characters (&lt;, &gt;, &quot; and &amp;)

Source: Character encodings in HTML by Wikipedia

  • You don't generally need to use HTML character entities if your editor supports Unicode.
  • the best practice is to forgo using HTML entities and use the actual UTF-8 character instead
  • If your pages are correctly encoded in utf-8 you should have no need for html entities, just use the characters you want directly.

Source: When should one use HTML entities? on Stack Overflow


I'm starting to understand that perhaps for most of the 2010s (or certainly during the early 2010s) it was probably still safer to mark up &ouml; rather than ö because a document might be retrieved by a user-agent (an older screen-reader for instance) which didn't understand UTF-8.

But I'm now concluding (not prematurely, I hope) that in 2020, UTF-8 is now so well established as the standard encoding for the web that it's now definitely safe to simply write ö (without escaping) in a document saved as UTF-8.

In summary, I understand that while I may still continue to use HTML entities for delimiters like &amp;, &lt;, &#39; etc. - I no longer need to concern myself with using HTML entities such as &agrave; and &ecirc; for Extended Latin characters.

Is this right?

  • I think you have been able to use UTF-8 on the web and not use most entities since like 2005 or maybe even earlier. – Stephen Ostermiller Apr 3 at 17:42
  • Sure, I don't doubt it. But (personally) in 2001-03, I was writing documents in Notepad and in 2003-13, I was writing documents in Notetab, so I couldn't save any of the documents I wrote as UTF-8. In 2013 I switched from Notetab to Sublime Text. – Rounin Apr 3 at 23:20
3
$ lynx -dump -source https://en.wikipedia.org | head -6

<!DOCTYPE html>
<html class="client-nojs" lang="en" dir="ltr">
<head>
<meta charset="UTF-8"/>
<title>Wikipedia, the free encyclopedia</title>

It seems to be working okay for Wikipedia, so I'd suggest that it should work okay for you too.

Editors like vim work with UTF-8 with no problem.

And with a bit of practice entering Unicode characters becomes almost automatic if one uses a multi or compose key. I type "é" frequently, without even thinking about it anymore: Multi, ', e. I don't think it would take long for me to learn thorn and eth: Multi, t, h and Multi, d, h.

I've set the Windows-Menu key to be my multi-key.

If you are using Linux, see /usr/share/X11/locale/en_US.UTF-8/Compose for a list of characters and their representation. (If there are characters not in that file, you can add them in your personal ~/.XCompose file.)

| improve this answer | |
  • All my documents have been saved and uploaded as UTF-8 since 2013. My question is whether in 2020 it's safe to drop &ouml; when writing HTML and write ö instead? Because - even in a UTF-8 document - I'm still not going to drop delimiter character escapes like &amp;, &lt; and &#39;. Was I drawing a false analogy in thinking that extended-Latin character escapes were like delimiter character escapes? – Rounin Apr 3 at 9:50
  • Note: the <meta> tag does not use and does not need a closing slash and never has in HTML. – Rob Apr 3 at 11:07
  • 1
    @Rob, there are many of us that believe that all tags should be closed. HTML allows it and XHTML requires it. Closing the tag in the given example was Wikipedia's choice. – Ray Butterworth Apr 3 at 13:05
  • 1
    @Rounin, the only character entities one needs are &amp, &lt;, &gt;, &quot;, and &apos. In fact, these are the only entities that XHTML allows: List of XML and HTML character entity references - Wikipedia – Ray Butterworth Apr 3 at 13:09
  • 1
    If you declared your character set to be ISO-8859-1 in your headers and meta tags, you shouldn't have even needed to use those entities. The problems stem from browsers using a default character set because it wasn't declared. When you don't declare a character set at all, then using any non-ASCII character is problematic and using entities is safer. – Stephen Ostermiller Apr 3 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.