HTML Attributes HTML
- HTML Introduction
- HTML Tags
- HTML Basic Examples
- HTML Headings
- HTML Paragraphs
- HTML Links
- HTML Images
- HTML Buttons
- HTML Lists
- HTML Attributes
- HTML Horizontal Rules
- The HTML <head> Element
- The HTML <pre> Element
- The HTML Style Attribute
- HTML Text Formatting
- HTML Quotation and Citation Elements
- HTML Comment Tags
- HTML Colors
- Styling HTML with CSS
- HTML Tables
- HTML Lists
- HTML The class Attribute
- HTML The id Attribute
- HTML Iframes
- HTML Form Elements
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">