Re: The style attribute, again

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/

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. 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".


-Andy

Received on Monday, 12 May 2003 15:25:22 UTC