What Is Kebab Case?
Kebab case is a case style where compound words are separated by dashes.
Kebab case is thus very similar to the snake case, which is a more popular case style in software development.
The most notable difference in the kebab case is usability. Most programming languages don’t allow using kebab case! This is why the kebab case is more common in URLs than in source code.
What Problem Does Kebab Case Solve?
Similar to other case styles, the kebab case improves the readability of compound words.
Consider a URL like this:
Because URLs don’t allow using blank spaces, having multi-word URL slugs chained together like this looks terrible. Especially with long URLs, the slugs would be completely unreadable with a convention like this.
This is where the kebab case helps. A URL doesn’t allow using blank spaces, but it does allow using dashes between the words.
As you can see, now the URL slug is much more readable and user-friendly.
Separating compound URL words with dashes is the second best thing you can do aside from separating them with spaces. This is what makes the kebab case the go-to naming convention for URL slugs.
Of course, you could use some other case style in URLs, such as the camel case. But it’s best to leave URLs not have capital letters. This is because you don’t want to make the URLs scream at the viewer.
Why Is It Called the Kebab Case?
I must admit I didn’t research what’s the reason for such a funny name because I think it’s obvious. Just look at this image and you’ll understand why.
In the kebab case, the words are separated by what looks like a skewer that sticks through chunks of kebab on the dining table.
Kebab Case vs Other Case Styles
In software development, there are four commonly recognized case styles:
- Camel Case
- Snake Case
- Pascal Case
- Kebab case
I’ve written a complete guide that summarizes these case styles and their usage.
To put it short, the kebab case is unlike any other case style because it’s generally not accepted in source code. As stated earlier, most programming languages don’t acknowledge dash as a valid symbol. Instead, developers must use underscores.
Today you learned what is the kebab case.
To take home, the kebab case is commonly used in URLs to separate words with dashes. This is because URLs don’t allow using blank spaces between compound words.
Kebab case is rarely used in programming source code because coding languages tend to prohibit using dashes between compound label names.
Thanks for reading. Happy coding!
About the Author
- I'm an entrepreneur and a blogger from Finland. My goal is to make coding and tech easier for you with comprehensive guides and reviews.
- Artificial Intelligence2023.03.14Best AI Tools of 2023 (Save Time & Boost Productivity)