What case should I use for my html, css, sass files?

By @martinzeltin · 2021-09-08 06:16

What case should I use for my html, css, sass files?

What is the best practice / style guide for naming my .html and .css and .sass files?

Should I use snake_case.html or kebab-case.sass or camelCase.css? What does the community use? Is there a generally accepted style guide for naming these types of files in a project?

  • By @mike · 2021-09-08 11:54

    Kebab-casing is generally preferred for a number of reasons, including readability.

    As far as I know, PHP is the only exception due to autoloading standards, but almost every other language I've ever worked with tends to lean on snake-casing and kebab-casing.

    For HTML, kebab-casing is definitely preferred if the file is to be accessed directly via the URL.

    • By @martinzeltin · 2021-09-08 12:14

      As far as I know, Typescript encourages the use of camelCase.ts files in the style guide.

  • By @innocenzi · 2021-09-08 07:22

    I personally use kebab-case because I find it more readable. Laravel uses the same conventions for its views, but people in different projects use different conventions and there is no consensus as far as I know.

    So I'd say, pick one and stick with it.