Adding Multimedia

Images

img tag is used to add images. img tag must contain atleast two attributes: src attribute and alt attribute.

Syntax for img tag is as follows:

<img src="image.jpg" alt="my image" />

Lets discuss the attributes defined inside the img tag.

  • src attribute

    src attribute tells the path of image to be used by the browser.
  • alt attribute

    alt attribute defines the alternative text for the image in case it is not available to the browser.
  • width attribute

    width attribute sets width of the image.
  • height attribute

    height attribute sets height of the image.

Audio and Video

<embed> tag is used to add audio and video files.

<embed> tag acts as a container for non-html elements like flash files, mp3 or mp4 files etc. It must contain src attribute.

Syntax for embed tag is defined as:

<embed src="mymusic.swf" width="200" height="100">

Following attributes are used inside embed tag:

  • src attribute

    src attribute tells the browser where to find the external file or non-html file.
  • width attribute

    width attribute sets width of the container.
  • height attribute

    height attribute sets height of the container.

Things to do

  • Open notepad or notepad++.
  • Add an image and an mp3 file in your html folder.
  • Write the following code:
    <!DOCTYPE html>
    <html>
    <head>
    	<title>Adding Multimedia</title>
    </head>
    <body>
    <img src=" image_name.png" alt="my logo"
     height="100" width="200" />
    <br />
    This is my image.
    <br /><br /><br />
    
    <embed src="audio_name.mp3" height="100" width="300">
    <br />
    This is my audio file.
    </body>
    </html>
    
  • Save the file as "multimedia.htm" and open it in a browser.
  • Open source code, make changes and see the result.
<< Links and Navigation Tables >>