logo CBCE Skill INDIA

Welcome to CBCE Skill INDIA. An ISO 9001:2015 Certified Autonomous Body | Best Quality Computer and Skills Training Provider Organization. Established Under Indian Trust Act 1882, Govt. of India. Identity No. - IV-190200628, and registered under NITI Aayog Govt. of India. Identity No. - WB/2023/0344555. Also registered under Ministry of Micro, Small & Medium Enterprises - MSME (Govt. of India). Registration Number - UDYAM-WB-06-0031863

HTML Image


HTML Image

  • In HTML, you can use the <img> tag to display images on a web page. The <img> tag is a self-closing tag, which means it doesn't require a closing tag. It only requires a few attributes to work correctly.

Here's the basic syntax for the <img> tag:

<img src="path/to/image.jpg" alt="Image Description">

Attributes:

  • src: This attribute is mandatory and specifies the source or URL of the image. It can be an absolute URL (e.g., "https://www.example.com/image.jpg") or a relative URL (e.g., "images/image.jpg" if the image is in the "images" folder of your website).
  • alt: This attribute provides alternative text for the image. It is essential for accessibility, as it will be displayed if the image cannot be loaded or for users with visual impairments who use screen readers. The text should describe the content or purpose of the image.

Example:

<img src="path/to/image.jpg" alt="Beautiful Scenery">
  • It's good practice to use the alt attribute even for decorative images. For example, if the image is purely decorative and doesn't convey any important information, you can use an empty alt attribute like this:
<img src="path/to/decorative-image.jpg" alt="">
  • This way, screen readers will ignore the image, and it won't be announced to users, improving the overall accessibility of your webpage.
  • You can also specify the width and height of the image using the width and height attributes, respectively. However, it's generally better to set the dimensions using CSS to maintain flexibility and responsiveness.
<img src="path/to/image.jpg" alt="Image Description" width="300" height="200">

 

 

Keep in mind that when using images on a website, it's essential to consider file size and optimize images for the web to improve loading times and user experience.

Thank You

Popular Post:

Give us your feedback!

Your email address will not be published. Required fields are marked *
0 Comments Write Comment