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

Joshua Prowse writes:
> 
> 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?

It's more an HTML question than a CSS one...

It's a discussion that the HTML WG had many years ago, probably in
1996 or so. The reason is that allowing style elements to appear after
the elements they apply to presupposes a renderer that keeps the whole
document tree in memory. Many browsers do that at the moment (at least
more so than back in 1996), but I don't think we should *require*
browsers to work that way. E.g., if they do CSS but not Javascript
(such as an application that formats documents for printing), then
they don't need to keep elements in memory after they have been
rendered.

Style rules that come after the elements will also cause flickering,
when the style of already displayed elements changes. (That already
happens with external style sheets in some browsers, but that can't be
avoided.)



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos/                              W3C/INRIA
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France

Received on Thursday, 8 August 2002 10:54:43 UTC