I was wondering if I can specify any CSS media types in the style attribute? and what can I specify in the style attribute?
Media queries work fine inside style tags and always have. They don't work in style attributes as only property/values are allowed in style attributes. You should avoid using the style attribute anyway unless you have a special case reason.
The media attribute specifies what media/device the CSS style is optimized for. This attribute is used to specify that the style is for special devices (like iPhone), speech or print media. Tip: This attribute can accept several values.
Yes, this is quite possible but only as using javascript event attributes in HTML elements.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With