Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to document CSS for a large site [closed]

Tags:

html

css

We maintain a fairly large site with a lot pages. As the pages grew, so did the HTML and CSS. Is there any good way to document these? Like which page uses a particular selector, etc. What's the best practice for maintaining CSS for a large site?

like image 258
Patrick Avatar asked Jul 03 '11 03:07

Patrick


People also ask

How many lines of CSS is too much?

It depends on what is your website supposed to do. If it is a small blog and you need, say, 3000 lines of CSS, that is probably too much. If it is an online store with multiple sections and a complicated layout, it might not be enough. It depends on your needs.

Is there a limit for CSS file?

Is there any size limit on CSS file or on the number of lines? The answer, for IE9 and lower, is yes, depending on what you mean by "lines" and "size limit". Size: the max size style sheet that IE9 and less will read is 288kb. Any styles after that mark do NOT get read.

Should you put all CSS in one file?

It depends on your use case. Usually everyone just smash a single css into the page and load it everywhere. If the site small and the css is only a few kB should be fine. once you get to the 100kb+ u probably better sppliting files into the most critical css and fonts so the first content is available without delays.


1 Answers

In my experience, CSS is not maintainable. If CSS were a room in your house, it's the basement...it collects things over the years and after a while you tend to have more stuff in it that is of no use vs. stuff you want to keep.

As such, I recommend starting fresh every few years.

Barring that, some suggestions:

  • Maintain the CSS dev-side in as many separate files as it makes sense to have. Use a minimizer to compress and combine it all into one file for deployment.
  • look into OOCSS (Object Oriented CSS) methods. I try to use that these days for sites that have large teams of developers. The basic concept is to have more class names in your HTML, but what class names you have are much more re-usable across the entire site, so your CSS files should remain more streamlined.
  • build component libraries. A major goal is to NOT have specific css for each individual page. Instead, leverage reusable code and design patterns across the site.
like image 166
DA. Avatar answered Oct 14 '22 05:10

DA.