views:

1543

answers:

6

When should I use ASP.NET Themes, and when should I use CSS? What are the advantages or disadvantages of using one over the other?

+8  A: 

Better together !

But Themes are not a replacement of CSS, or they're not built for the equvalent purpose to the CSS. It's purpose is to define different themes on your application and to change them with a single line. Themes can include CSS files, image files and skins.

With skins, you can define styles for asp.net controls, so it includes complex and complete solution. For example you can define a gridview and define its style and attributes. You can define it application-wide.

So you I think they are better together, but not equivalent to compare.

Canavar
You can also do this using the CssClass tag attribute of most ASP.Net controls.
Ioxp
so themes only apply to web server controls?
Igor Zelaya
Good point. The Themes can be used for application programming as well but for the purpose of this post it was in reference to ASP.Net which is for the web.
Ioxp
@loxp - You mean themes can also be used on Desktop Applications? What I meant with my last comment was that if you can apply themes only to controls that start with a <asp:.. element
Igor Zelaya
@Ioxp : But you can manage a theme at one place without writing CssClass tags.@Igor Zelaya : You you can also define Html controls.
Canavar
+11  A: 

I would recommend using CSS over Themes. The reason for this is in CSS you can modify your styles to they work with all browsers. You can do the same thing with themes but Microsoft's designer is notorious for fixing the things that you fixed to make them work on all browsers so its counter productive. Stick to CSS you will spend less time mucking about.

Ioxp
Themes only really make sense when you are implementing "skinning" type functionality, or if you are unfamiliar with the browser client technologies.
Ishmael
Ishmael, CSS is also great for skinning purposes. Just load a different CSS file and you done. Even better. Since CSS stands for "cacscading ..." you can overvwrite existing style definitions or combine them :)
Robert
+1  A: 

Themes come in really handy if you are using Membership ,profiles and personalization. Other than that yes the Visual Studio Designer is notorious. You should use CSS extensively if you have browser compatibility in mind.

Perpetualcoder
Why are they handy in this situations? Because of the existing controls integration?
Igor Zelaya
@Igor = Themes and controls based arch for personalization which can be made dependent on Membership and Profile fit in pretty well. http://codeidol.com/asp/asp.net-illustrated/Profiles,-Personalization,-and-Themes/Using-Themes-to-Personalize-Your-Site/ is a simple example
Perpetualcoder
+1  A: 

As mentioned, they are not mutually exclusive. I've had the occasion to have multiple themes that in themselves contain their own set of CSS/Media/Skin files that are appropriate based on site configuration.

bxlewi1
+2  A: 

If you are considering to hire an external design agency or designer you are much better off with CSS, since CSS is well known to them - since Themes are much more developer/VS centric.

Robert
+1  A: 

You should combine them. Use your css files in the theme folder for your normal styling of all the html elements in your website (include all the generated elements).

In the skin file of a control, you can set the default css class. Other properties like the layout and default behavior of the elements (sample: calender control) are editable here too.

Skin files are good for all layout specific configuration you can't easily do with css, but with the .net properties of the controls.

michl86
one sample for skin specific is Calendar.DayNameFormat
michl86