What is Kebab-Case?
Kebab-case (also called spinal-case, lisp-case, or slug-case) uses lowercase letters with hyphens as separators. The name comes from the appearance of words skewered together on a hyphen, like food on a kebab skewer.
Examples: background-color, user-profile, get-started, my-awesome-project
Why CSS Uses Kebab-Case
Kebab-case is the official naming convention for CSS properties and is strongly recommended for class names and IDs:
background-color: red;
font-family: Arial;
border-top-left-radius: 8px;
The reason is historical — CSS was designed before camelCase became dominant in JavaScript, and hyphen-separated names were the web standard at the time.
Kebab-Case for URLs
Kebab-case is the SEO best practice for URL slugs:
- ✓
/what-is-kebab-case— readable, SEO-friendly - ✗
/what_is_kebab_case— Google treats underscores as word connectors, not separators - ✗
/WhatIsKebabCase— case-sensitive URLs can cause duplicate content
Google's John Mueller has specifically recommended hyphens over underscores in URLs because search engines treat hyphens as word separators.
Where Kebab-Case is Used
| Context | Example |
|---|
|---|---|
| CSS properties | `background-color`, `font-size` |
|---|---|
| CSS class names | `.btn-primary`, `.card-header` |
| HTML data attributes | `data-user-id`, `data-is-active` |
| URL slugs | `/blog/what-is-kebab-case/` |
| npm package names | `react-router`, `lodash-es` |
| Kubernetes resources | `my-deployment`, `api-service` |
| Vue component files | `user-card.vue`, `nav-bar.vue` |
| Lisp/Clojure | `user-name`, `get-user-by-id` |
Kebab-Case vs snake_case for URLs
Both are used, but hyphens are preferred for URLs:
| Feature | kebab-case | snake_case |
|---|
|---|---|---|
| Google treatment | Word separator | Word connector |
|---|---|---|
| Readability | High | High |
| Typing | Easy | Requires Shift |
| SEO | Better | Slightly worse |
| Human-friendliness | High | Moderate |
When NOT to Use Kebab-Case
Kebab-case cannot be used for identifiers in most programming languages because the hyphen conflicts with the subtraction operator:
first-namein JavaScript would be interpreted asfirst minus name
Use camelCase or snake_case for variable and function names in code.