By Andrew Flick and Devin Rader
Here's a question for all of you rapid application Web developers: Do you find yourself setting the same properties multiple times? For instance, have you set the font or the color of a font more than once in an application, setting it to the exact same specifications each time? If you answered "yes" to either of the preceding questions, you may be a candidate for cascading style sheets, better known as CSS.
CSS has been around for a long time, but we felt it was a necessary addition to our tips and tricks section because, even to this day, people are afraid of utilizing the technology. It seems that many people still insist on either writing the same blocks of code over and over (and over) again, or they click on different controls in Visual Studio.NET and set the exact same settings multiple times, as if CSS is some sort of voodoo. There is absolutely nothing wrong with that; however, if you want to make an application-wide style change, it does make maintenance quite a pain.
Currently there are two separate versions of CSS in existence: CSS1 and CSS2. All CSS1 style sheets work and are valid CSS2 style sheets; however, CSS2 adds the capability for the designer to target different end-devices (such as printers and handheld devices). Furthermore, according to the W3C, CSS2 supports content positioning, downloadable fonts, table layouts, internationalization, and many more features geared for UI development. For the purpose of this article, we'll discuss the basics of CSS1, because many developers are targeting IE as their end-browser and IE does not fully support CSS2 as, according to Microsoft Watch, Microsoft views the current implementation of CSS2 as "flawed." Finally, CSS3 is currently under development, so it will be exciting to see if this gains traction in the Microsoft world and acceptance of the W3C. So, utilizing CSS1, we'll discuss the structure of CSS, inline vs. external styles, CSS classes, precedence, and inheritance.
Read | ASP.Net Pro