Can I specify the CSS media types in the style attribute?

advertisements

I was wondering if I can specify any CSS media types in the style attribute? and what can I specify in the style attribute?


Not that I know of. Your best bet is to define a class rather than inline styles. Then, you'll have more flexibility.

You can include different stylesheets by specifying the media attribute on your link tag to include a stylesheet, or you can also specify that rules within a stylesheet should only apply to a given media.

For example:

Including a CSS file by specifying a media:

<link media="print" href="styles.css" type="text/css" rel="stylesheet">

Specifying a media within a stylesheet:

@media print
{
    .myStyle { display: none; }
}

Also, see the W3C media type list for all your options.