What is the function of the 'src' attribute in an image tag?

Prepare for the WDI General Assembly Assessment Test. Study using flashcards and multiple choice questions with hints and detailed explanations. Master your skills and boost your chances of success in the exam!

The 'src' attribute in an image tag is used to specify the source of the image. This means that it provides the URL or the relative path to the image file that should be displayed on the webpage. When a browser encounters an image tag with the 'src' attribute, it retrieves the image from the defined location and renders it on the page.

By accurately pointing to the image's location, the 'src' attribute ensures that users see the correct image when they load a webpage. Without this attribute, the browser would not know where to find the image, resulting in a broken image link or nothing being displayed at all.

The other options address aspects of image handling that are not defined by the 'src' attribute itself. The type of the image would typically be inferred from the file extension in the URL provided in the 'src', while styling and resizing an image are done using CSS rather than attributes in the image tag.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy