div background image in html code example

Example 1: div background image

#avatar {
    /* This image is 687 wide by 1024 tall, similar to your aspect ratio */
    background-image: url('http://i.stack.imgur.com/Dj7eP.jpg');
    
    /* make a square container */
    width: 150px;
    height: 150px;

    /* fill the container, preserving aspect ratio, and cropping to fit */
    background-size: cover;

    /* center the image vertically and horizontally */
    background-position: top center;

    /* round the edges to a circle with border radius 1/2 container size */
    border-radius: 50%;
}

Example 2: html background image

<!-- Code by Scratchy -->
<!-- Twitter: @S_cratchy-->

<head>
  <style>
    body {
      background-image: url(https://wallup.net/wp-content/uploads/2019/09/110394-cats-grey-kittens-fluffy-fat-grass-animals-cat-kitten-baby-cute-748x468.jpg) 
    }
  </style>
  
  <body>
    You have set the background image!
    
    
    
  </body>

Example 3: how to change background image in html

<style>
div {
  background-image: url('img_girl.jpg');
}
</style>