Re: @media in style attribute

Philip Hoyt wrote:

> I've been trying to find a way to specify media type for a css rule in
> the style attribute of xhtml. Something like
> <img src="printLogo.gif" style="@media print {display: block} @media
> screen {display:none}" /> but this doesn't seem to be part of any
> specfication, and at least that syntax doesn't work in any modern
> browsers. Seems like it might be useful functionality.

This is indeed not part of any specification, neither for HTML nor for CSS. 
There is a draft that describes it[1] (not the same syntax, but it allows that 
functionality), but the use cases are so rare, that nothing has happened with it 
since and there is currently no sign that anything will.

If you want the style rule inside the document, you can use the MEDIA attribute 
of the STYLE element, or put the @media inside the STYLE element. If that is not 
enough, than there is a good chance that your architecture isn't optimal.


   Bert Bos                                ( W 3 C )                               W3C/ERCIM                             2004 Rt des Lucioles / BP 93
   +33 4 93 65 76 92               06902 Sophia Antipolis Cedex, France

Received on Thursday, 20 May 2004 14:45:07 UTC