Open In App

How to specify media type of the target URL in HTML5 ?

Last Updated : 06 Jun, 2023
Like Article

You can easily specify the media type of the target URL in HTML5 using the media attribute of HTML. This attribute is used to specify that the target URL is designed for special devices (like iPhone, Android, etc), speech or print media, projectors, tv, and so on.


<a href="" media="screen" target=”_blank”> Click here</a>

Note: The media attribute can only be used if the href attribute is used as it specifies the linked document. The media attribute is used to specify how and on which devices the linked document would appear and be compatible.

Various devices values:

  • all: It is most suited for all media-type devices.
  • screen: It is used for computer screens, smartphones, etc.
  • tv: It is used for television-type devices (low resolution, or the one with limited scroll ability).
  • print: It is used for the print preview mode/printed page’s mode.

Example: In this example, we will see the use of media attribute


<!DOCTYPE html>
        h1 {
            color: green;
        <h1>Welcome To GFG</h1>
        <a href=""
           media="print" target="_blank">
            Click here for print media
        <br /><br />
        <a href=""
           media="tv" target="_blank">
            Click here for screen media


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads