Skip to main content

Src Attribute

The src attribute is a standard HTML attribute used to specify the source URL for embedded content, such as images, scripts, or iframes.

Usage

~index.html
<img src="{image.jpg}" alt="An example image">

How it Works

  • The browser reads the src attribute value.
  • It then requests the specified resource from the server.
  • Once received, the resource is loaded into the element.

Error Handling

If the resource cannot be loaded, the browser typically shows a placeholder or error icon. For images, the alt text is displayed if provided

Note

note

The src attribute is essential for loading external resources and is crucial for proper rendering of media elements in web pages