HTML Attributes

All HTML elements can have attributes and attributes provide additional information about an element. attributes are always specified in the start tag. attributes usually come in name/value pairs like: name="value".

The src Attribute

HTML images are defined with the <img> tag.

The filename of the image source is specified in the src attribute:


<img src="" alt="" width="120" height="40" />

The image size is specified in pixels. i.e width: 120px, height:40px

img alt attribute is also useful if the image does not exist.

img alt attribute specifies an alternative text to be used, when an image cannot be displayed.