Skip to content
Related Articles

Related Articles

Improve Article

How to create a link with a media attribute in HTML5 ?

  • Difficulty Level : Expert
  • Last Updated : 26 May, 2021

The <link> media Attribute attribute specifies which media/device is being optimized for the target resource. This attribute is typically used in conjunction with CSS stylesheets to specify different styles for various media types and connecting to external stylesheets, allowing the user to select the most appropriate one for the device.

This attribute accepts a variety of values. It needs a media type/media query to be its value. 

Syntax:

<link media="value">

Operators:

  • and: It specifies an AND operator
  • not: It specifies a NOT operator
  •   ,  :  It specifies an OR operator

Example 1: The “print” value is used for print preview mode for printed pages.



HTML




<!DOCTYPE html>
<html>
  <body>
    <a href="https://www.geeksforgeeks.org/" media="print, handheld">
     GeeksforGeeks
    </a>
  </body>
</html>

Output:

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :