HTML

Insert Image


To insert an image in HTML, you can use the <img> tag. Here is an example of how to do it:

Syntex

<!DOCTYPE html>
<html>
<head>
    <title>Insert Image Example</title>
</head>
<body>
    <h1>My Image</h1>
    <img src="path/to/your/image.jpg" alt="Description of the image" width="500" height="600">
</body>
</html>

 

Example:

<!DOCTYPE html>
<html>
<head>
    <title>Insert Image Example</title>
</head>
<body>
    <h1>My Image</h1>
    <img src="https://codersmile.com/codersmile.svg" alt="Description of the image" width="500" height="600">
</body>
</html>

Here's a breakdown of the attributes used in the <img> tag:

  • src: Specifies the path to the image you want to display. This can be a relative path, an absolute path, or a URL.
  • alt: Provides alternative text for the image if it cannot be displayed. This is important for accessibility.
  • width: Sets the width of the image (optional).
  • height: Sets the height of the image (optional).

Replace "path/to/your/image.jpg" with the actual path to your image file.