Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the name for hyphen-separated case?

This is PascalCase: SomeSymbol

This is camelCase: someSymbol

This is snake_case: some_symbol

So my questions is whether there is a widely accepted name for this: some-symbol? It's commonly used in url's.

like image 481
lmirosevic Avatar asked Jun 30 '12 10:06

lmirosevic


People also ask

What is hyphen separated?

A hyphen joins two or more words together while a dash separates words into parenthetical statements. The two are sometimes confused because they look so similar, but their usage is different. Hyphens are not separated by spaces, while a dash has a space on either side.

What are dashes snake case?

Snake case is a naming convention in which a developer replaces spaces between words with an underscore.

What is meant by kebab case?

Kebab case -- or kebab-case -- is a programming variable naming convention where a developer replaces the spaces between words with a dash. Programming variable names should be descriptive. Two or more words are often required to properly convey a resource's meaning.

What is a lowercase dash called?

En dash. An en dash is a typographic dash that is as wide as a lowercase "n" character. These dashes are typically used to denote ranges of numbers, as in 3–7. You create an en dash by pressing Ctrl and the minus sign on the numeric keypad.


2 Answers

There isn't really a standard name for this case convention, and there is disagreement over what it should be called.

That said, as of 2019, there is a strong case to be made that kebab-case is winning:

https://trends.google.com/trends/explore?date=all&q=kebab-case,spinal-case,lisp-case,dash-case,caterpillar-case

spinal-case is a distant second, and no other terms have any traction at all.

Additionally, kebab-case has entered the lexicon of several javascript code libraries, e.g.:

  • https://lodash.com/docs/#kebabCase
  • https://www.npmjs.com/package/kebab-case
  • https://vuejs.org/v2/guide/components-props.html#Prop-Casing-camelCase-vs-kebab-case

However, there are still other terms that people use. Lisp has used this convention for decades as described in this Wikipedia entry, so some people have described it as lisp-case. Some other forms I've seen include caterpillar-case, dash-case, and hyphen-case, but none of these is standard.

So the answer to your question is: No, there isn't a single widely-accepted name for this case convention analogous to snake_case or camelCase, which are widely-accepted.

like image 57
Ben Lee Avatar answered Nov 28 '22 14:11

Ben Lee


It's referred to as kebab-case. See lodash docs.

like image 22
jwfearn Avatar answered Nov 28 '22 15:11

jwfearn