I am developing a website in asp.net 4.0. While designing I have a question
- Is it good to have separate css for every web page?
OR
- Have all styles in one css?
Please tell me what is the best solution?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Aside from the caching and minimizing benefits outlined in other answers, consider that your CSS is essentially assigning a theme to your website or web application. If you think about how a theme works in your favorite media player or web browser, when you apply that theme, it generally affects the entire application, not just one part of it.
Therefore, if you think of your CSS as a theme, it then becomes easier for your designers to then change the look and feel of your site without ever having to touch a single line of HTML. Since a good design practice is to keep your HTML, JavaScript, and CSS completely separate, it makes it easier to make changes to one without having to worry about changes to the others. This reduces chances for bugs, since things that don’t change remain stable.
What’s more, your designers only have to make changes to 1 file in order to create a new theme, which makes their job easier. It makes your job easier because you don’t have to go through and fix a bunch of broken HTML and JavaScript because CSS experts had to make changes to code that might not be their area of expertise.
A good example of this practice is Stack Exchange. Stack Overflow, Server Fault, Super User, and Stack Apps all run on the same Q&A engine, but each one has a slightly different theme. To create a completely new Q&A site, the frontend changes pretty much involve only CSS changes. This is how Stack Exchange can get away with having only 1 designer, Jin, who manages the designs of every single Q&A site on the network. What makes his job easier is the standardization and simplicity, and following the “don’t repeat yourself” rule of thumb.
From looking at the browser source, you can see there is only 1 CSS file: