« RailsConf 2011: Fat Models Aren't Enough | Main | RailsConf 2011: Deploying with Bundler »

May 18, 2011

RailsConf 2011: The Future of Stylesheets with Sass

Listening to Chris Eppstein at RailsConf 2011 this morning talk about Sass., a technology for making CSS stylesheets more robust with preprocessing.

Rational, problems it solves, syntax, best practices.

What is Sass? Syntactically Awesome StyleSheets, a stylesheet generator. CSS is 14 years old, selectors, properties, and values. Web developers need to support many browsers, many output types. CSS 3 will have 33 new selectors, 120 new properties, new @rules, but no new syntax. CSS was created for designers who wouldn't have to do any abstraction.

The reality is that most stylesheets are written by programmers.

Sass comes from real world experience, brings software development methodologies to stylesheets. Brings variables, mixins, inheritance, transformations, loops, and more to CSS.

CSS has many problems. Sass has some cool stuff to address them:

- Variables: define at the top of the file and then include the variable in the stylesheet
- Color transformations is awesome: define one color and then a bunch of variations of that color to get a
- @import directive lets you pull in files, build smaller CSS sheets and then only include what you need
- nested selectors let you simplify definition of selectors

As the session winds down I added "gem 'haml'" to my Rails 3 Gemfile and did a "bundle install" to start using this now.

Posted by mike at May 18, 2011 9:49 AM