Skip to main content

Command Palette

Search for a command to run...

HTML Images

Published
•1 min read•View as Markdown
HTML Images

HTML Images

  • Images can improve the design and the appearance of a web page.

👉 HTML Images Syntax

  • The HTML <img> tag is used to embed an image in a web page.
  • Images are not technically inserted into a web page; images are linked to web pages. The <img> tag creates a holding space for the referenced image.
  • The <img> tag is empty, it contains attributes only, and does not have a closing tag.
  • The <img> tag has two required attributes:
  • src - Specifies the path to the image
  • alt - Specifies an alternate text for the image

image.png

👉 The src Attribute

  • The required src attribute specifies the path (URL) to the image.
  • You can use the style attribute to specify the width and height of an image.

👉 Example➖

image.png

👉 The alt Attribute

  • The required alt attribute provides an alternate text for an image, if the user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).
  • The value of the alt attribute should describe the image:
  • If a browser cannot find an image, it will display the value of the alt attribute:

👉 Example➖

image.png


image.png> Download our HTML & CSS Visual Treat! ebook Here: Click here