HTML Image Attributes


The <img> tag within HTML incorporates multiple attributes which allow developers to establish:

 

  • The source of the image
  • The alternative text
  • The size, loading behavior, and style

<img> Attributes

Attribute Description
src Specifies the path/URL of the image
alt Alternative text shown when the image can't be loaded
width Width of the image (in px or %)
height Height of the image (in px or %)

Example

<img src="logo.png" alt="Company Logo" width="200" height="100"> 

Image Attributes

Attribute Description
title Tooltip shown when user hovers over the image
loading Controls when the image should be loaded (lazy, eager) style Inline CSS styling
class Assigns a CSS class for styling
id Assigns a unique ID for styling or scripting
usemap Associates the image with an image map
longdesc URL to a detailed description (rarely used)



OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.