Horje
How to create HTML src Attribute

The <img> tag is used to embed an image in an HTML page. The src attribute specifies the path to the image to be displayed:


There are two ways to specify the URL in the src attribute:
1. Absolute URL - Links to an external image that is hosted on another website. Example: src="https://www.w3schools.com/images/img_girl.jpg".
Notes: External images might be under copyright. If you do not get permission to use it, you may be in violation of copyright laws. In addition, you cannot control external images; it can suddenly be removed or changed.
2. Relative URL - Links to an image that is hosted within the website. Here, the URL does not include the domain name. If the URL begins without a slash, it will be relative to the current page. Example: src="img_girl.jpg". If the URL begins with a slash, it will be relative to the domain. Example: src="/images/img_girl.jpg".
Tip: It is almost always best to use relative URLs. They will not break if you change domain.

How is to look a HTML src Attribute

Following is sample
src="https://itupto.com/avatar.png"

Full Example of HTML src Attribute

The src attribute specifies the URL or path of the resource file. The URL points to the media file to display (images) or play (audio and video). The browser uses the URL to locate and load the media file. The URL can be internal (from same website) or external (another website).
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>The src Attribute</h2>
<p>HTML images are defined with the img tag, and the filename of the image source is specified in the src attribute:</p>

<img src="https://itupto.com/avatar.png" width="100" height="100">

</body>
</html>

Output should be:

Full Example of HTML src Attribute
Reffered: https://www.w3schools.com/html/tryit.asp?filename=tryhtml_attributes_img_src





Related Articles
What is HTML Attributes HTML Attributes
How to create HTML href Attribute HTML Attributes
How to create HTML src Attribute HTML Attributes
How to create HTML width and height Attributes HTML Attributes
How to create HTML alt Attribute HTML Attributes
How to create HTML style Attribute HTML Attributes
How to create lang Attribute HTML Attributes
How to create HTML title Attribute HTML Attributes
How to create HTML Single or Double Quotes HTML Attributes
What is HTML Headings HTML Attributes
How to create HTML Headings HTML Attributes
What is Headings Are Important HTML Attributes
How to create HTML Bigger Headings HTML Attributes

Single Articles
How is to look a HTML src AttributeHTML Attributes
Full Example of HTML src AttributeHTML Attributes

Read Full:
HTML Attributes
Category:
Web Tutorial
Sub Category:
HTML Attributes
Uploaded:
1 year ago
Uploaded by:
Admin
Views:
167



Share on: