How to Insert image on Web Pages
The
<img>
tag is used to insert images in the HTML documents. It is an empty element and contains attributes only.
The syntax of the
<img>
tag can be given with:
<img src="url" alt="some_text">
Each image must carry at least two attributes: the
src
attribute, and an alt
attribute.
The
src
attribute tells the browser where to find the image. Its value is the URL of the image file.
the
alt
attribute provides an alternative text for the image, if it is unavailable or cannot be displayed for some reason. Its value should be a meaningful substitute for the image.Set the Width and Height of an Image
The
width
and height
attributes are used to specify the width and height of an image.
The values of these attributes are interpreted in pixels by default.
<img src="dog.jpg" alt="dogs" width="300" height="300">
You can also use the
style
attribute to specify width and height for the images.
<img src="dog.jpg" alt="dogs" style="width: 300px; height: 300px;">
source code :
<html>
<head>
<title>Sample</title>
</head>
<body>
<h1>image </h1>
<img src ="dog.jpg"alt="dog" height="300px" width="350px"/>
</body>
</html>
output:
0 comments:
Post a Comment