- From: Coises <Randy@Coises.com>
- Date: Thu, 08 Aug 2002 13:08:14 -0700
- To: <www-style@w3.org>
[Thu, 8 Aug 2002 09:04:09 -0400] Joshua Prowse: >What reason is there for restricting the style tag to the head of the document? >Why not allow it anywhere in the document so that <style> tags that are placed >lower override earlier ones? I *think* you mean you'd like to be able to do something like this: <STYLE>P {color: red}</STYLE> <P>Paragraph 1</P> <P>Paragraph 2</P> <STYLE>P {color: green}</STYLE> <P>Paragraph 3</P> <P>Paragraph 4</P> and have "Paragraph 1" and "Paragraph 2" in shown in red, while "Paragraph 3" and "Paragraph 4" would appear in green. The biggest problem with this is that it breaks the normal paradigm of "nesting" within HTML: information is carried "inward" to containing blocks, not "downward" to following blocks, in HTML. The consistent exception is the <HEAD> section, which contains information that applies to the entire document. (One other exception is <BASEFONT>... but that tag is pretty much a mess. I imagine it gives browser authors nightmares.) The closest you can come to the above (that I can think of) is to use "neutral" tags (i.e., <DIV> or <SPAN>) to enclose sections that should be styled differently, and define classes in the (embedded or external) style sheet that specify the particular characteristics needed; for example: <STYLE TYPE="text/css"> *.Pred P {color: red} *.Pgreen P {color: green} </STYLE> ... <DIV CLASS="Pred"> <P>Paragraph 1</P> <P>Paragraph 2</P> </DIV> <DIV CLASS="Pgreen"> <P>Paragraph 3</P> <P>Paragraph 4</P> </DIV> Better is if you can tie the classes to something meaningful rather than just presentational attributes; that is, so that the newly-introduced <DIV> elements (and the classes to which they are assigned) represent a logical grouping for which presentation is changed for some reason (e.g., one represents deleted text, or one represents a quote, or whatever). If you can name the classes that way, it will be easier for others (or you yourself, after a few months or years) to maintain the document when it needs to be updated, because the logic of its design will be more apparent. -- Randall Joseph Fellmy aka Randy@Coises.com
Received on Thursday, 8 August 2002 16:08:46 UTC