Why use skins if we can handle server controls with CSS in ASP.Net

css

The main difference between themes/skins and CSS are the HTML & Server Side Controls (SSC) only. We use skin files to format & cosmetics SSC which are not in HTML like <asp:Label>, <asp:TextBox> & </asp:RadioButtonList> etc…

But what if we use the rendered HTML SSC in CSS instead skin files to handle <asp:Label> & <asp:TextBox> etc…

ie: when SSC <asp:TextBox> rendered on browsers it shows <input type="text"> so if we write following style in my CSS file instead Skin, it also works…

input[type=text], textarea, select { 
    outline: none;   
    padding: 3px 0px 3px 3px;
    margin: 5px 1px 3px 0px;
    border: 1px solid #cccccc;  
    background: #ffffff;
    width: 150px;
    color: #484848;
    font-size:
    12px; 
}

So my question is, if we still can handle SSC with CSS do we really need skins? Or if I am missing anything please correct me, thanks.

Best Answer

It's a question of choice; I have never needed to use skins, I have always been able to do all the styling I wanted to with pure css.

Looking at your example it is purely the look and feel of controls you want to control - so I see no reason for you to use skins. Html for mark-up, JavaScript for client-side functionality and css for how things look. Keeping your mark-up free from script or style has its advantages and css is the best tool for styling.

I wouldn't mix and match css and skins for the simple reason that I would then find it more difficult to know whether I needed to look in a skin file or a css file to make a style change.

If you had need of setting properties on your SSC then a skin file would be something to consider, but as we've both said you're only looking for styling then I wouldn't complicate things by introducing skin files. StackOverflow has an answer to skin vs css that might be interesting to read.

Related Topic