HTML Images

Bookmark
Learn about using images in web pages.

Images can be added to a HTML web page using <img> tag. Image tag element does not contain a closing tag. Following are the attributes of HTML img tag element.

Name Value Description
src relative or absolute url source address of the image and this is mandatory.
alt text if the image cannot be displayed for any reason, then this alternate text will be displayed.
width number in pixel or percentage display width to be used in browser to show the image. Image will be stretched or shrinked to fit the given number.
height number in pixel or percentage display height to be used in browser to show the image. Image will be stretched or shrinked to fit the given number.
longdesc URL URL of a description of the image, which supplements alt text.
  • HTML <img> tag can be used within any HTML tag element that allows to embed a content, for example <p> and <a>.
  • General image formats that are supported by common browsers are JPEG, GIF, PNG, SVG, BMP.

HTML Image <img> Example

<img src="html.jpg" alt="html">
html

Exception Occured:

TypeErrorException
Messageerror_log(app.log): Failed to open stream: Permission denied
File/home/dh_czz6eb/tutorialwalk.com/common/error.php
Line36
Trace#0 (): log_error(2, 'error_log(app.log): Failed to open stream: Permission denied', '/home/dh_czz6eb/tutorialwalk.com/common/error.php', 36)
#1 /home/dh_czz6eb/tutorialwalk.com/common/error.php(36): error_log('20-04-2024 06:07:00 am (IST),/home/dh_czz6eb/tutorialwalk.com/common/common.php,193,0,ErrorException,Optional parameter $per_page declared before required parameter $href is implicitly treated as a required parameter,/html/html-images.html,#0 /home/dh_czz6eb/tutorialwalk.com/common/error.php(115): log_error(8192, 'Optional parame...', '/home/dh_czz6eb...', 193)
#1 [internal function]: check_for_fatal()
#2 {main}
', 3, 'app.log')
#2 /home/dh_czz6eb/tutorialwalk.com/common/error.php(8): log_exception(ErrorException)
#3 /home/dh_czz6eb/tutorialwalk.com/common/error.php(115): log_error(8192, 'Optional parameter $per_page declared before required parameter $href is implicitly treated as a required parameter', '/home/dh_czz6eb/tutorialwalk.com/common/common.php', 193)
#4 (): check_for_fatal()
REQUEST_URI/html/html-images.html