Sunday, 5 February 2012

Using Cascading Style Sheets (CSS) | ASP.Net Tutorial | ASP.Net Tutorial PDF


    It’s clear that controls make it easy for us to reuse pieces of functionality in multiple locations. For example, I can’t imagine an easier way to add calendars to many web forms than to use the Calendar web server control.

    However, controls don’t solve the problem of defining and managing the visual elements of your web site. Modern web sites need constant updating to keep them fresh, and it’s not much fun editing hundreds of pages by hand just to change a border color, for example, and then having to check everything to ensure that your changes are consistent. The process is even more painful if your client wants a more serious update, like a rearrangement of the components on the pages.

    The good news is that this maintenance work can be made a lot easier if you plan ahead, correctly follow a few basic rules, and efficiently use the tools that HTML and ASP.NET offer you.

     An essential tool for building reusable visual styles is Cascading Style Sheets (CSS). HTML was initially designed to deliver simple text content, and didn’t address the specifics of how particular items appeared in the browser. HTML left it to the individual browsers to work out these intricacies, and tailor the output to the limitations and strengths of users’ machines. While we can change font styles, sizes, colors, and so on using HTML tags, this practice can lead to verbose code and pages that are very hard to restyle at a later date.

     CSS gives web developers the power to create one set of styles in a single location, and to apply those styles to all of the pages in our web site. All of the pages to which the style sheet is applied will display the same fonts, colors, and sizes, giving the site a consistent feel. Regardless of whether our site contains three pages or 300, when we alter the styles in the style sheet, our changes are immediately applied to all the pages that use that style sheet.