Paulo Phagula

Musings and Scribbles on Software Development

dash(hyphen), ndash and mdash

This article is more related to grammar and small details in language rather than the usual (coding). It tells how (accidentally) through reading code I came to learn that we actually have three (3) kinds of dashes instead of just one. I wrote this short post just so: we don't forget about them; their differences and when to use each.

It is common that developers use some separator on the title tag to separate the actual page title from the site name, normally using a pipe or mid-dot or even a dash/hyphen, thus rendering a title like: About - StackOverflow.

Recently, as I was reading some HTML code, I noticed that the developer choose to use as separator the HTML entity: &ndash; like <title>page title &ndash; sitename</title>. Which was curious to me… I mean, why not just use - ?

I ended up googling about it and found an article which aptly explains that there’s actually 3 kinds of dashes, each meant for a specific purpose and with a different graphic representation. The article is just a bit lengthy, so for short bellow are the differences and suggested usage of each of the dashes.

  • dash/hyphen - used to indicate breaks within words that wrap at the end of a line; to connect compound words like “mass-produced”; to connect grouped numbers like in a phone number (258 84-850-4509)
  • n dash - has the width of a capital N and should be used to join ranges, like 2000–2010 or July–October 2010
  • m dash - has the width of a capital M and is meant to set apart a unique idea from the main clause in a sentence or to show when dialog has been interrupted: like “Hunter strode into the room — was he mad?”

This is one of those small things in language that is commonly missed but is good know.

Please, use syntax highlighting in your comments, to make them more readable.