Img, Elements, Attributes
Img, Elements, Attributes
- Basic Structure:
- Examples: <h1>,<div>,<p>
- Characteristics:
Syntax of Attributes
- Attributes are added within the opening tag of an element and follow this
format:
<element attribute="value">Content</element>
- `src` (Source):
- Specifies the path to the image file.
- This path can be a relative URL (based on the location of the HTML
file) or an absolute URL (complete path).
- `height`:
- Defines the height of the image in pixels or as a percentage of its
original size.
- `width`:
- Defines the width of the image in pixels or as a percentage of its
original size.
- Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Tag</title>
</head>
<body>
<h1>Image Tag</h1>
<p>here we will learn how to add image</p>
<img src="https://images.pexels.com/photos/994605/pexels-photo-
994605.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1" alt="sea image"
height="200" width="200">
<img src="https://images.pexels.com/photos/189349/pexels-photo-
189349.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1" alt="sun set"
height="200" width="300">
</body>
</html>