Syntax:
<img src="image url" alt="alternatetext">
1.src
The src attribute is used to describe the source, path, or URL of the image that we want to display on the web page.
The src attribute is used to describe the source, path, or URL of the image that we want to display on the web page.
2. alt
The alt attribute is used to put alternative text. The text displays when the image is not displayed by different problems and the text describes the image in words.
Example
<!DOCTYPE html> <html> <body> <img src="nature.jpg" alt="beautiful nature"> </body> </html>
We can specify the width and height of the image by using the width and height attributes. It is not recommended we can use CSS styles instead of width and height attributes.
Example: Image resizing by using width and height attribute
<!DOCTYPE html> <html> <body> <h2> Image resizing</h2> <img src="nature.jpg" height="150" width="250" alt="beautiful nature"> </body> </html>
<!DOCTYPE html> <html> <body> <h2> Image resizing </h2> <img src="nature.jpg" alt="beautiful nature" style="width: 250px; height: 150px;"> </body> </html>
Image from another website/server
You can insert an image URL from another server or website to the src tag as follows.
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDU1G69_A7bARQ3atCv3KlHsBXhRwd40FvW0ici18BQ_AdTcvgj2bEeDeEmZYKFbqCYOh_uJVIfnNsFUoLVHsV1BfHvpEMAglNLAGYvIzcC26CBVMS4GsXJt1kIkpZstIivpKhVzxmcIc/w320-h180/20210708_212406.jpg" alt="">
How to use Image as a link?
We can add a link to an image by using the <a> tag as follows.
<a href="https://dgtteck.blogspot.com/"> <img src="nature.jpg" alt="beautiful nature" style="width: 250px; height: 150px;"> </a>
HTML permits to display of animated GIFs.
Example
<img src="dgtube.gif" alt="subscribe to dg tube">
0 Comments