Search Header Logo
image in html

image in html

Assessment

Presentation

Computers

9th Grade

Practice Problem

Hard

Created by

Mohammad Fuad

FREE Resource

23 Slides • 0 Questions

1

media

Sprint 4.1 Images in HTML

Unit 4 More on HTML

Mr. mohammad fuad
Grade : Nine
Term : two
Date : 8-12_3_2025

media

2

media

Learning Objective

use img tag, src and alt attribute to insert an image in the web page;

add border to the images;

add space around the images;

resize the images;

align text with the images.

2

3

media

Image tag

4

4

media

Image tag

The <img> tag specifies images within HTML pages. To
embed image links on a web page, we must use the
<img> tag.

Syntax:
<img src=" " alt=" " width=" " height=" ">

Note:
The img tag is an empty tag that only has attributes.
It doesn't use closing tags, so it doesn't have any.

5

5

media

Image tag

Example:

6

6

media

Attributes of Image Tag

7

7

media

Attributes of image tag

The following are attributes of the <img> tag:

The src attribute

The src attribute in the <img> tag defines the path or URL (Uniform Resource Locator) to the image.
The location of the image can be a web server or your local computer.

The width attribute

It is used to specify the width of the image.

8

8

media

Place the Image at Center

9

9

media

Place the Image at Center

Step 1: Add the HTML code within the body tag of the web page about_me.html

Step 2: Add CSS within the style block present in the head section of the web page.

10

.center {

display: block;
margin-left: auto;
margin-right: auto;
width: 50%;

}

<img src = "Nora_learning_journey_home.jpg"
width=700px height=250px alt="My learning journey"
class = "center">

10

media

Output

12

11

media

Adding Border to Images

13

12

media

Adding Border to Images

We can implement the style attribute to give the image a border.

The hspace and vspace attributes in the image tag provide the
option to add space around the images. These attributes provide
horizontal and vertical spacing, respectively.

Note

hspace is used to add space to the right and left of the images.
vspace is used to add space above and below the images

Syntax

14

<img src = "path"

hspace = "space in pixels"

vspace =

"space in pixels">

13

media

Adding Border to Images

Step 1: Add a solid brown color border with a dimension of 4 px to the image.
Step 2: Add horizontal <hspace> spacing of 120 and vertical <vspace> spacing of 30 around the
image.

Syntax

16

<img src = "path"

hspace = "space in pixels"

vspace =

"space in pixels">

14

media

Output

17

15

media

Adding Border to Images

Step 3: Open the web page biography.html
Step 4: Add the HTML codes within the body tag of the
web page.

Step 5: Add CSS within the style block present in the head
section of the web page.

18

<img src = "path"

hspace = "space in pixels"

vspace =

"space in pixels">

.center {

display: block;
margin-left: auto;
margin-right: auto;
width: 50%;

}

16

media

Output

19

17

media

Image Gallery

20

18

media

Image Gallery

Let's create another web page Image Gallery for the same website.

Step 1: Create a new web page MyGallery.html.

Step 2: Add a background image and the heading, My Tribe.

21

<html>
<head>

<title>Image gallery</title>
<style>

.center{

display: block;
margin-left: auto;
margin-right: auto;
width: 50%;

}

</style>

19

media

Image Gallery

23

</head>

<body bgcolor = "#FFFACD">

<img src = "Nora_learning_journey_mytribe.jpg" width=900px height=250px

alt="My tribe" class = "center" style="border:4px solid brown" hspace = 120 vspace
= 30>

<h1 align="center" style="font-size:50px; color: #BA55D3;"> My Tribe </h1>

</body>

</html>

20

media

Output

The output will be

24

21

media

​Activity :

22

media

23

media
media

Sprint 4.1 Images in HTML

Unit 4 More on HTML

Mr. mohammad fuad
Grade : Nine
Term : two
Date : 8-12_3_2025

media

Show answer

Auto Play

Slide 1 / 23

SLIDE