HTML Attributes HTML

HTML Attributes  

HTML Attributes

The src Attribute

HTML images are defined with the <img> tag.

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

The width and height Attributes

 HTML images also have width and height attributes, which specifies the width and height of the image:

<img src="https://www.w3tpoint.com/uploads/w3tpoint.png" width="500" height="600"> 

The alt Attribute

The alt attribute specifies an alternative text to be used if an image cannot be displayed.

The value of the alt attribute can be read by screen readers. This way, someone "listening" to the webpage, e.g. a vision-impaired person, can "hear" the element.

The alt attribute is also useful if the image cannot be displayed (e.g. if it does not exist):

Example

Image with alt attribute

<img src="https://www.w3tpoint.com/uploads/w3tpoint.png" alt="W3tpoint logo" width="500" height="300">

No image but alt attribute

<img src="https://www.w3tpoint.com/uploads/noimg.png" alt="W3tpoint logo" width="500" height="300">

 

Download free E-book of HTML


#askProgrammers
Learn Programming for Free


Join Programmers Community on Telegram


Talk with Experienced Programmers


Just drop a message, we will solve your queries