When writing traditional CSS, you end up with the same color values repeated all over the place, making it a burden to change them. In fact, this is the biggest reason why I believe SASS leads to better design-it allows you to treat colors as a pallette.Ī good design generally involves only a handful of colors, plus various shades and tints. Also, since variables can only contain strings, there is no need to add quotes around the value.Ī great use for variables is to store color values. The other important difference is that variables are declared with a colon instead of an equals sign. Don’t worry about that limitation as we’ll get past that in a bit. The biggest difference between a variable in SASS and a variable in PHP, is that a SASS variable can only be a string. Variables act almost exactly like you’d expect them to from using them in PHP. One of the coolest things about SASS is variables. Everything you know about CSS applies to SASS, no need to relearn properties, rules, and selectors. You can easily use either a GUI tool like CodeKit, or a grunt task to compile it.įinally, remember that valid CSS is valid SASS. SASS compilers are outside the scope of this article, but it isn’t a big deal. sass syntax, which is similar to PAML and HAML.Īlso, SASS can’t be loaded by your browser. Second, it’s important to keep in mind that SASS has two different file extensions. Before We Beginīefore we start, there are two things to keep in mind: First, I’m assuming you have a basic familiarity with PHP form WordPress development. Most importantly, SASS allows us to establish and use patterns in our code without resorting to cut and paste. Just like any new language, things will be a little different, but the foundation is the same. In this article, I will be comparing SASS to the conventions of PHP, which are familiar to WordPress developers. variables, arrays, and control structures-it’s easy to learn. ![]() The best part about SASS is that its an actual programming language, which means if you know the basics of how a programming language works-i.e. Not only is SASS more efficient, but I think it leads to an overall better design. One of the reasons that CSS bothers me so much is that writing it involves a constant violation of the golden rule of programming: “don’t repeat yourself.” While I’m still not a designer, learning to use the CSS pre-processor SASS has allowed me to write CSS in a sane manner. Like it or not, if you’re a WordPress developer CSS is part of your life.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |