Dipali Y.
Dipali Y.

Reputation: 113

How to set height and with in background image in html

<html>
<head>

</head>
<body background="D:\Desert.jpg">
         HI..This IS DESERT image.
</body>
</html>

When I run This Code Image Is Repeat.I Want Full size image in screen.Without Css. I want this in HTML.

Upvotes: 1

Views: 3289

Answers (5)

Avishka Dambawinna
Avishka Dambawinna

Reputation: 1215

You have to use CSS for that.If you really need pure html use a large image

<body style = "background-repeat: no-repeat; background-size: cover; background-image: url("D:\Desert.jpg");height:500px;width:100%;">

ankita patel mentioned it above

Upvotes: 0

Tanaka
Tanaka

Reputation: 301

I would just add a " background-repeat: no-repeat;" to stop the image from repeating.

.image{
  background:url('https://beebom-redkapmedia.netdna-ssl.com/wp-content/uploads/2016/01/Reverse-Image-Search-Engines-Apps-And-Its-Uses-2016.jpg');
  height:500px;
  width:100%
  color:white;
  background-repeat: no-repeat;
}
<div class='image'>
         HI..This IS DESERT image.
</div>

Upvotes: 0

Maulik
Maulik

Reputation: 785

Here Is Fiddle

.image{
  background:url('https://beebom-redkapmedia.netdna-ssl.com/wp-content/uploads/2016/01/Reverse-Image-Search-Engines-Apps-And-Its-Uses-2016.jpg');
  height:500px;
  color:white;
}
<div class='image'>
         HI..This IS DESERT image.
</div>

Upvotes: 1

Srinibas Biswal
Srinibas Biswal

Reputation: 21

<div style="background-image: url(https://cdn.pixabay.com/photo/2016/03/21/10/44/desert-1270345_960_720.jpg);background-position: center;background-repeat: no-repeat;background-size: contain;height: 500px;width: 500px;">

You can give css properties in the html code itself by adding a style in the html tag.
asumming that you have a 500px height and width div Here : background-position: center (means the image will be in center)
background-size: contain (means the image will be contained inside the div and you can change to cover to show it as a cover image)

Upvotes: 1

ankita patel
ankita patel

Reputation: 4251

You can give in body tag like

<body style="background-repeat: no-repeat; background-size: cover; background-image: url("D:\Desert.jpg");height:500px;width:100%;">

Upvotes: 2

Related Questions