89.8k views
4 votes
What attributes are valid for the tag?

User Lukas Thum
by
7.3k points

1 Answer

5 votes

Final answer:

The tag in HTML has several valid attributes, including 'src', 'alt', 'title', 'width', 'height', 'class', 'id', 'style', and 'usemap', which control the display and behavior of the image on a webpage.

Step-by-step explanation:

The <img> tag is used to embed images in an HTML document. It has several attributes that can be used to specify how the image should be displayed and behave on a webpage. Here are some commonly used attributes:

  • src (required): Specifies the path to the image file.
  • alt: Provides alternative text for the image if it cannot be displayed.
  • title: Adds a title to the image that appears as a tooltip when the mouse hovers over it.
  • width: Sets the width of the image in pixels or percentage.
  • height: Sets the height of the image in pixels or percentage.
  • class: Assigns one or more class names to the image, usually for CSS styling.
  • id: Sets a unique identifier for the image.
  • style: Applies inline CSS styles to the image.
  • usemap: Associates the image with an image map.

These attributes allow a web developer to control the appearance and functionality of images embedded in a webpage.

User Matovitch
by
8.5k points