
170 views
How to Insert Image in HTML
To insert an image in HTML, you can use the <img>
tag. Here’s an example of how to insert an image:
HTML
<img src="image.jpg" alt="Description of the image">
In the example above:
- The
src
attribute specifies the source URL or file path of the image. You need to replace “image.jpg” with the actual file name or URL of your image. - The
alt
attribute provides alternative text for the image. It is used to describe the image when it cannot be displayed or for accessibility purposes. It’s important to include descriptive alt text that conveys the meaning or context of the image.
You can also include additional attributes to control the appearance and behavior of the image, such as width, height, styling, or linking the image to another webpage. Here’s an example with some additional attributes:
HTML
<img src="image.jpg" alt="Description of the image" width="300" height="200" style="border: 1px solid black;">
In this example:
- The
width
andheight
attributes specify the dimensions of the image in pixels. - The
style
attribute allows you to apply inline CSS styles to the image. In this case, a border of 1 pixel solid black is applied to the image.
Remember to replace “image.jpg” with the correct file name or URL of your image, and provide appropriate alt text for accessibility and SEO purposes.