HTML Media

What is a HTML media?

The HTML <media> tag is not a valid HTML tag. It is likely that you may be referring to the <audio> or <video> tags, which are used to embed audio and video content in an HTML document, respectively. These tags allow you to control the playback of audio and video files and can be used in conjunction with other HTML tags, such as <source> and <track>, to provide additional functionality.

This attribute can be applied for <a>, <area>, <link>, <source> and <style>.

Example: using <a> element

<!DOCTYPE html>
<html>

<body>
    <p>
        <a href="https://fullstackadda.com/" media="print and (resolution:200dpi)">Open media attribute page for print</a>
    </p>
</body>

</html>

Example: using <link> element

<!DOCTYPE html>
<html>

<head>
    <link href="tag_link.asp" rel="parent" rev="subsection" hreflang="en">
</head>

<body>
    <p>Fullstackadda</p>
    <p>A blog that is decided to help people wo want to learn programming</p>
</body>

</html>

 Example: using <style> element

<!DOCTYPE html>
<html>

<head>
    <style>
        h1 {
            color: #FF0000;
        }

        p {
            color: #0000FF;
        }

        body {
            background-color: yellow;
        }
    </style>
    <style media="print">
        h1 {
            color: #000000;
        }

        p {
            color: #000000;
        }

        body {
            background-color: #FFFFFF;
        }
    </style>
</head>

<body>
    <h1>fullstackadda.com</h1>
    <a href="fullstackadda.com" target="_blank">Click here</a>
    <p>If you try to print you will see that it is styled with the media="print" stylesheet.</p>
</body>

</html>

Output

Here is a list of media tags that are available to design media-rich pages.

ELEMENTDESCRIPTION
<audio>Creates a player for sound such as music, sound effects, or others
<video>Creates a video player on a page
<source>Adds a media source for a <video>, <audio>, or <picture>
<track>Adds a text track, such as, subtitles and captions, to the media
<embed>Creates a container for an external resource
<iframe>Creates a frame in which another web page can be embedded
<svg>Displays an scalable vector image
<canvas>Creates a graphics container where JavaScript can draw
<img>Displays an image
<area>Specifies a map area for an image
<map>Defines a client-side image map, i.e. an image with clickable areas
<figure>Displays self-contained content, usually an image
<figcaption>Adds a caption to a <figure> (image) element
HTML Media
  1. The HTML <media> tag is not a valid HTML tag. It is likely that you may be referring to the <audio> or <video> tags, which are used to embed audio and video content in an HTML document, respectively.