An additional advantage to this method is that the browser will cache the style sheet locally and reduce the number of calls to your server. Of course, this could be a bad thing if you were planning on changing the style sheet frequently, but in my experience that's pretty rare.
Actually, I'd be interested in hearing about solutions to this as I've tackled this a completely different way in Mason:
/* keys %head */
% foreach (keys %head) {
<% $_ %> { font-size: <% $head{$_} %>pt; color: <% $colours{'head'} %>
+; \
% if ($isNetscape) {
font-family: <% $font_family %>; padding-left: 10px; padding-top: 10px
+; \
% } else {
margin-left: 10px; margin-top: 10px; \
% }
}
% }
/* keys %text */
% foreach (keys %text) {
<% $_ %> { font-size: <% $text{$_} %>pt; \
% if ($isNetscape) {
color: <% $colours{'text'} %>; font-family: <% $font_family %>; paddin
+g-left: 10px; \
% }
% if (($isIE) && ($_ eq 'P')) {
line-height: <% $line_height %>pt; margin-left: 10px; \
% }
% if ($_ eq 'UL') {
list-style-type: circle; \
% }
}
% }
%head = (
'H1' => $font_size + 6,
'H2' => $font_size + 4,
'H3' => $font_size + 2,
'H4' => $font_size,
'H5' => $font_size
);
%colours = (
'text' => '#FFFFFF',
'head' => '#99CCFF',
'link' => '#CCCCCC',
'vlink' => '#999999',
'alink' => '#99CCFF',
'list' => '#99CCFF',
'smalllist' => '#99CCFF',
'listheaders' => '#99FFFF',
'highlight' => '#FFFFFF',
'data' => '#FF9933'
);
I need clean this up a lot, but it was the way that (kind of) made sense to me when I was trying to build a style sheet that would adapt according to browser support/os/individual preferences... |