W3C home > Mailing lists > Public > www-html@w3.org > May 2003

RE: The style attribute, again

From: Peter Foti (PeterF) <PeterF@SystolicNetworks.com>
Date: Mon, 12 May 2003 16:12:33 -0400
Message-ID: <A10A983C9DFBD4119F0300104B2EA6B726027C@ZIPPY>
To: "'Andy'" <aholmes84@shaw.ca>, "'www-html@w3.org'" <www-html@w3.org>

Andy wrote:
>Peter Foti (PeterF) wrote:
>
>>...
>>
>>My thought on the subject was that there should be a STYLE 
>element allowed
>>within the body of a document that could be applied to a 
>certain scope.
>>Perhaps a STYLE tag with an attribute that signifies an IDREF that
>>identifies the container where the style should be applied.  
>For example:
>>
>><body>
>>   <div class="b">
>>      No styles here.
>>   </div>
>>   <style scope="imported">
>>   .b { font-weight: bold; }
>>   </style>
>>   <div id="imported">
>>      This text was <span class="b">imported</span>.
>>   </div>
>></body>
>>
>>Or perhaps some method of using namespaces to siginify where the style
>>should be applied.  I never really put much thought into it, 
>and no one
>>seemed to take much notice when I suggested it.
>>
>>  
>>
>I must disagree. Using inline style just creates too many unnecessary 
>problems, many of which are outlined in 
>http://devedge.netscape.com/viewsource/2003/xhtml-style-script/
>


A valid point.  However, since XHTML 2.0 is already breaking backwards
compatibility, why not just say that this new "in-body" style element can't
contain those invalid characters?  I'm sure there must be one way or another
to allow inline styles in XHTML 2.0.


>Your example causes conflictions as well using the 'id' attribute to 
>apply your style, in addition to the fact that the style attribute is 
>only allowed in the 'head' element.


I know the style attribute is only allowed in the head.  My point was that
by giving it a scope, you could also allow it in the body as well, so that
when someone had to paste the XML from one document into another, the styles
associated with those elements could be passed along as well.  Personally, I
would never use a method like this, but there are those that I think would
find it useful.  Perhaps it should have a different element name than
"style" though, to stress the difference from the <head> version.

And what's wrong with using the 'id' attribute?  For applying a scope to
something, that seems appropriate to me, since you want to be sure the item
is unique (and the id should cover that).


> The obvious solution to the above 
>problem is to simple use a different class name such as 
>'imported-b' or 
>a selector such as:
>
>    div#imported span.b {
>       font-weight: bold;
>    }
>
>Selectors like this have been present in CSS since CSS1. CSS2 and CSS3 
>(will) expand greatly upon selectors' "accuracy".


But a different class name (attempting to be unique) does NOT handle the
case of a style being applied innappropriately to some data outside of the
scope of the imported data.  The problem with trying to use a different
classname is that you never know what pre-existing style definitions might
already be setup in the document that the data is being pasted to.  However,
the second approach you suggested would be acceptable I think (using an ID
selector)... but ONLY if the style values could be included within the body.

I'm by no means suggesting this is a good idea, or even workable.  I'm just
thinking out loud and thought it might be an idea that could be refined into
something that would please everyone.  :)

-Peter



>
>
>-Andy
>
Received on Monday, 12 May 2003 16:00:05 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:55 GMT