Re: Why is the style tag restricted to the head?

At 1:08 PM -0700 8/8/02, Coises wrote:
>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.

I don't know what Joshua wanted, but I'd like to be able to do something
like this:

   <style type="text/css"> p { color: red; } </style>
   <p>paragraph 1</p>
   <p>paragraph 2</p>
   <style type="text/css"> p { color: green; } </style>
   <p>paragraph 3</p>
   <p>paragraph 4</p>

This satisfies your statement in which you say:
At 1:08 PM -0700 8/8/02, Coises wrote:
>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 example I gave above does not break this paradigm; instead, it relies
on it.  In this case, the first style element would set up a rule
which applies only within the context of the containing block, that is to
say, the first div element.  The same goes for the second.

Why would you want to do this?  Because that way you can take any part
of the document and have specific styles that apply to it.  You can yank
out the second <div> and have it "work correctly" when you paste it into
another document, but you can't do that with style tags in the head of
the page.


Kynn Bartlett <>       
Chief Technologist, Idyll Mountain  
Next Book: Teach Yourself CSS in 24
Kynn on Web Accessibility ->>

Received on Thursday, 8 August 2002 16:27:30 UTC