Answers for "how to create a background image in html"

CSS
17

how to set background image in html

<!-- Add image by a HTML element: -->
<div style="background-image: url('img.jpg');">

<!-- Add image by a <style> element: -->
<style>
div {
  background-image: url('img.jpg');
}
</style>

<!-- Add to the entire body: -->
<style>
body {
  background-image: url('img.jpg');
}
</style>
Posted by: Guest on September-16-2020
0

body background image in html

body {
  background-image: url('img_girl.jpg');
}
Posted by: Guest on December-24-2020
3

how to add background in html

<!DOCTYPE HTML>
<html lang=us>
  <meta charset=UTF-8>
  //the following code within the style tags is CSS.
<style>
  /*this is a body tag. After specifying 
  that we want to affect the whole body,
  we add {}, and write the background color
  we want to change it to. */
  body{background:rgb(255,0,0);
  }
  /* this is a class, which we have named green. we add {}, then
  write the background color we want.*/
  .green{background:green}
   /* this is an id, which we have named blue. we add {}, then
  write the background color we want.*/
  #blue{background:blue}
</style>

<body>
This background is red.
  // you must make sure to note that when you add a background to
  a paragraph, you must add a class or id, name it, then style it 
  as seen above.  with tags HTML already recognizes, however, you 
  don't have to do anything more than shown above.
  <p class="green">
  This background is green.</p>
  <p id="blue">This background is blue.</p>

</body>

</style>
</html>
Posted by: Guest on April-15-2020
0

how to make a still background image in html

<body style="background-image: url(your image url here);
  background-repeat: no-repeat;
  background-attachment: fixed;">
Posted by: Guest on January-15-2021
-1

background image html

<!DOCTYPE html>
<html>
	<head>
      <style>
      	.bg-img {
          background-image: url("https://cleananddelicious.com/wp-content/uploads/2016/03/Avocad0-CD.jpg");
        }
      </style>
 	</head>
  	<body>
  		<div class="bg-img">
          <h1>The background of this div will be an avocado</h1>
        </div>
  	</body>
</html>
Posted by: Guest on January-21-2021

Code answers related to "how to create a background image in html"

Browse Popular Code Answers by Language