WordPress Typography, Hyphens and Dashes

While try­ing to give examples of code in the last couple of posts I found out an inter­est­ing typo­graph­ical fea­ture of Word­Press. A single hyphen is rendered as a hyphen, two hyphens are rendered as an en dash and three hyphens are rendered as an em dash. In visual terms:

  • - = -
  • – = –
  • — = —

Which means try­ing to show examples with con­di­tional com­ments, when ever I typed <!– it rendered as < !– and the dif­fer­ence as you can see if dif­fi­cult to pick between <!- and < !–. So after a little frus­tra­tion, a lot of search­ing an finally find­ing this topic in the Word­Press sup­port. It is the file functions-formatting.php in the wp-includes folder that is the culprit.

So if you need to give code examples and want two hyphens (or two dashes for the non typo­graph­ic­ally inclined) not to be auto­mat­ic­ally trans­lated in a single en dash, you need to com­ment out the fol­low­ing line $curl = str_replace('--', '&#8211;', $curl); in functions-formatting.php. See­ing I prefer to use &#8211; for – and &#8212; for — I also com­men­ted out &#8212;$curl = str_replace('---', '&#8212;', $curl); $curl = str_replace(' -- ', ' &#8212; ', $curl);.

If you want to know the cor­rect use of hyphens, en dashes and em dashes I sug­gest you read The Trouble With EM ‛n EN (and Other Shady Char­ac­ters).

Updated 7th Feb­ru­ary: Mark Boulton’s series Five Simple Steps to Type­set­ting on the web has a great art­icle on dashes. Expla­ing the dif­fer­ences between hyphens, en dashes and em dashes and when and how to use them on the web.

One Response to “WordPress Typography, Hyphens and Dashes”

  1. Myles Eftos Says:

    Word­press really needs to sup­port the code or pre tag…

    Might have to hack my version…

Affiliates

Google
text advertising by
Powered by Reseller Zoom