What is the purpose of the media attribute in the <style> element?

The media attribute specifies the media type for which the styles are intended.

The media attribute in the <style> element allows you to define which media the styles should be applied to, using a media query. This is useful for applying different styles based on the device's characteristics, such as screen width or resolution. If the attribute is not specified, the styles apply to all media types by default.

<style media="screen and (max-width: 600px)">
  p { color: blue; }
</style>
More cards6
Show all