- From: Peter Foti (PeterF) <PeterF@SystolicNetworks.com>
- Date: Fri, 9 Aug 2002 10:27:36 -0400
- To: "'www-style@w3.org'" <www-style@w3.org>
> <div> > <style type="text/css"> p { color: red; } </style> > <p>paragraph 1</p> > <p>paragraph 2</p> > </div> > <div> > <style type="text/css"> p { color: green; } </style> > <p>paragraph 3</p> > <p>paragraph 4</p> > </div> > > 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. This is an interesting concept. However, I can think of 2 very large problems. 1. It would not be backwards compatible with the the way style sheets work today because if you were to apply the styles only to the containing block, then style sheets included in the <head> would not be applied to elements in the <body>. To demonstrate this, I have replaced the <div> elements in your example with the <head> and <body> elements, and removed the <p> elements from the <head>, and modified the stylesheets. <head> <style type="text/css"> p { color: red; } </style> </head> <body> <style type="text/css"> div { color: green; } </style> <p>paragraph 3</p> <p>paragraph 4</p> <div>some block</div> </body> In the example above, the style on the <p> elements would not be applied as they are today. > > 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. 2. What would happen then for sites that allow users to enter data to be displayed, like on a message board? Suppose a user posts some style that adversely affects the layout of the rest of the page? For example: <div> <style type="text/css"> div { position : absolute; width : 100%; height : 100%; background-color : Black; top : 0px; left : 0px; } </style> <div>Ha Ha! I am blocking your entire page!</div> </div> This essentially opens up a very large security whole, in that you can cover the entire contents of a web page. This in itself is a good enough reason to NOT allow <style> elements within the body of a document. Regards, Peter Foti > > --Kynn > > -- > Kynn Bartlett <kynn@idyllmtn.com> http://kynn.com > Chief Technologist, Idyll Mountain http://idyllmtn.com > Next Book: Teach Yourself CSS in 24 http://cssin24hours.com > Kynn on Web Accessibility ->> http://kynn.com/+sitepoint >
Received on Friday, 9 August 2002 10:21:41 UTC