Skip to main content

Breadcrumb

  1. Home

CSS File Name Epiphany

I never liked CSS file names like `site.css`, `styles.css` or even `article.css`. There has to be something better...

Main navigation

  • Home

User account menu

  • Log in

Discuss

tim@timverly.com

  • organization

  • linux

  • programs

  • growth

  • employees

  • minimal

  • docker

  • whatis

  • hiring

  • code

  • how dos

  • css

  • howto

  • organic

  • computers

  • companies

  • motivation

  • cpu

Submitted by timverly on Sun, 04/03/2016 - 14:43

I don't think I've seen this done anywhere, although it's not like I'm looking in the CSS files of all the sites I go to.  So if you're doing this, let me know how it's working for you!

Instead of organizing CSS files by site area - `site.css`, `blocks.css`, `sidebar.css`, etc - add another organization level by CSS ruleset:

  • `text.site.css`
    • contains anything involving the display of text:
      • `font-family`, `font-size`, `text-align`, ...
  • `color.site.css`
    • contains anything involving the site's color scheme:
      • `color`, `border-color`, `background-color`, ...
  • `structure.site.css`
    • contains anything that changes the size and position of elements, either the element itself or surrounding elements:
      • `height`, `width`, `margin`, `padding`, `position`, `float`, `line-height`

Then to override the styles for specific site areas, name files such as:

  • `home.structure.css`
  • `blocks.color.css`
  • `article.text.css`

Now if I'm looking at my search block, and don't think the font size is quite right, I know exactly where to go to edit it.  And if there are inherited values, I can clearly see what effect the change I make will have, without having to sift through a bunch of non-font-related CSS rules.

Because when do you really have to work on both your site's color scheme and it's typography at the same time?  Multi-tasking is evil, remember!?  Work on one thing at a time, and you do everything right.

And even if you're in full styling mode, going back and forth between a few files is betting than going up and down in a single file.

Oh, and the real epiphany ... couldn't a well-structured CSS file system remove the need for SCSS files?

 

Food for thought!

 

Tags
css
code
organization

Recent content

How Computers (Really) Work!
1 hour 8 minutes ago
What is whatis?
4 hours 59 minutes ago
Minimalist Docker
1 hour 24 minutes ago
Evaluating Employees
15 seconds ago
Growing a Company
33 minutes 50 seconds ago
CSS File Name Epiphany
20 minutes 6 seconds ago
timverly
Where there is work, there is progress