Tuesday, 2 October 2007

Application of multiple CSS Tags & Inheritence

Following my back2basics thing at the moment.

CSS does not support inheritence of tags, however it does support the application of multiple tags.

Therefore the following allows you to apply 2 styles to one label.

<asp:gridview id="myGrid" autogeneratecolumns="true" cssclass="GridStyle1 GridStyle2" runat="server"></asp:gridview>

Interestingly enough i was interested in the order of preference (for style clashes). Using Visual Studio 2008 and its CSS properties functionality, i discovered that the order of preference comes from the order of the tags in the CSS file (first style found takes precedence).

Therefore be careful about how you order your styles in CSS.

No comments: