Re: CSS inheritance - newbie question

by "EB" <doublebase(at)wanadoo.nl>

 Date:  Wed, 3 Oct 2001 16:37:16 +0200
 To:  "HWG Techniques" <hwg-techniques(at)hwg.org>
 References:  localhost
  todo: View Thread, Original
----- Original Message -----
From: John Aitchison <jaitchis(at)hwy.com.au>
Subject: CSS inheritance - newbie question

| It seems to me fairly usual practice for people to define the style
| elements 'independently'
<snip />
| but my gut feel is that it would be better (? more maintainable) to
| define the style of a group of elements together and then to specify
| the exceptions eg
<snip />

imo there's no easy answer to that.
it depends on the amount of equal/different properties,
and in a big style sheet this can become quite complex.
if 9 out of 10 properties are equal for several selectors
your gut may be right ;-)
at any rate you should compress the declarations.

this example:
H1 { font-family: arial, tahoma, helvetica, sans-serif;
font-style: normal;
font-size: 18pt;
font-weight: bold;
color: #003366;
text-align: center;
text-transform: None }

is the same as:
h1 {
font: bold 18pt arial,tahoma,helvetica,sans-serif;
color: #036;
background: should_be_defined;
text-align: center}

oh well, maybe text-transform *is* necessary because it's inherited from
/somewhere/

| Is there some reason for NOT doing it the way I suggest? ie defining
| a common base style and noting the exceptions?

imo this often makes it more difficult to maintain
(you [or your client] may change your mind 
about what the exceptions should be)
or to detect problems later on,
and often doesn't save considerable download time.

rule of thumb: kiss ;-)
the cascading order is complex enough in itself (iirc):
author's style sheet: !important >
user's style sheet: !important >
author's html attribute declarations >
author's style sheet >
user's style sheet >
ua's default settings

add to this:
possible use of linked, imported, embedded and inline declarations
by the author + common browser bugs and confusion regarding
inheritance becomes the norm rather than the exception anyway.

| 2. This CSS comes from a real site that has been mentioned on this
| list before. I still have not come up to speed on the arguments for px
| vs em vs pt,
<snip />
pt is useless considering different monitor resolutions 
(eg windows 96dpi, mac 72dpi);
em is the best/only unit suitable for text because it doesn't fumble with
the client's preferences, but must be hidden from ie3 and nn4.
px is the only one that works good across all the popular visual user
agents, but will usually be unresizable due to broken css support.

btw, it's a common error to classify px as absolute,
it's relative (to the canvas resolution).

on the opposite, pt (and in, cm etc) _are_ absolute units,
and not suitable for the medium screen.

| but I note that the above CSS uses a mixture of px and
| pt. Is this more likely an oversight or is it possibly a design
| consideration that I am unaware of?

maybe someone decided to save some bucks and do the updates himself ;-)

hth, eric

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA