Getting the best out of Cascading Style Sheets (CSS)
Cascading Style Sheets (CSS) have really changed the way we think about web page design, and they’ve certainly made creating awesome designs much simpler than it used to be. Still, for such a great technology, there’s a huge amount that web designers and developers need to learn in order to truly master the entire skill set required to earn the title of CSS Ninja.
1. Create an organized library of CSS that fits your design philosophy
Every time you do something in CSS that achieves a perfect result, you should categorize it and file it away, so that when you need to do the same task again, you already have the perfect code available and ready to adapt to suit the needs of the new project.
2. Use the console to help you debug stuff
The console is a really helpful sidekick if you learn how to use it properly. There’s one super JavaScript command you should never be shy about using, which is the log command.
3. Minification is not normally necessary for ordinary CSS files
Minifying is a big trend, but it’s not very useful when you’re trying to debug a problem to have to go and find some un-minified version of your CSS file before you can track down the bug, then rewrite it, and then minify everything again. What a waste of time just to save a few bytes! Really, with internet speeds as they are, worrying about the spaces in your CSS file is just silly. Consider instead not uploading that annoying and unnecessary Flash element. That’s more of a problem!
4. Tidy code is good code!
If you just take a moment to indent all your CSS lines correctly and also group the attributes in some logical way (eg. put all the color information together, put all the positioning information together) or put the attributes in alphabetical order, it will be much easier for you to read and find the attribute you’re looking for and want to change.
5. Some truths are not entirely true
You can only have one element on a page with a particular ID attribute, right? No, actually that’s wrong. But you’ll see it written everywhere. The truth is that although using multiple elements with the same ID is not normally a good idea, you can still do it if you want or need to.
6. Avoid shorthand declarations
This is related to tip 3, and it’s based on the same thing. You don’t need to save space, and shorthand just leads to more confusion.
1. Create an organized library of CSS that fits your design philosophy
Every time you do something in CSS that achieves a perfect result, you should categorize it and file it away, so that when you need to do the same task again, you already have the perfect code available and ready to adapt to suit the needs of the new project.
2. Use the console to help you debug stuff
The console is a really helpful sidekick if you learn how to use it properly. There’s one super JavaScript command you should never be shy about using, which is the log command.
3. Minification is not normally necessary for ordinary CSS files
Minifying is a big trend, but it’s not very useful when you’re trying to debug a problem to have to go and find some un-minified version of your CSS file before you can track down the bug, then rewrite it, and then minify everything again. What a waste of time just to save a few bytes! Really, with internet speeds as they are, worrying about the spaces in your CSS file is just silly. Consider instead not uploading that annoying and unnecessary Flash element. That’s more of a problem!
4. Tidy code is good code!
If you just take a moment to indent all your CSS lines correctly and also group the attributes in some logical way (eg. put all the color information together, put all the positioning information together) or put the attributes in alphabetical order, it will be much easier for you to read and find the attribute you’re looking for and want to change.
5. Some truths are not entirely true
You can only have one element on a page with a particular ID attribute, right? No, actually that’s wrong. But you’ll see it written everywhere. The truth is that although using multiple elements with the same ID is not normally a good idea, you can still do it if you want or need to.
6. Avoid shorthand declarations
This is related to tip 3, and it’s based on the same thing. You don’t need to save space, and shorthand just leads to more confusion.
Comments
Post a Comment