How to Set Background Image In Html | How to add background image in css | Background-image: url path | Html Background | The ACX



HTML Background Images

Add a background image on an HTML element, usingstyleattribute in Html and the CSS background-image property:- 

Ex.

<div style="background-image: url('(photo name).jpg');">

Also We Can Use <style> element for background image, in the <head> section:- 

Ex.

<style>
div { 

background-image: url('(photo name).jpg');

}
</style>

Background Cover

If you want the background image to cover the entire element then, you can set the background-size property to cover.Also, Set the element is always covered and set the background-attachment property to fixed:-

Ex.

<style>
body {
  background-image: url('(photo name).jpg');

  background-size: cover;

  background-attachment: fixed;

  background-repeat: no-repeat;

}
</style>


Comments

Popular posts from this blog

How to install Pip pillow | Install Pip Pillow | Python pip | Python pillow tutorial

How to create Cardview with Toast | Cardview | Toast | Android Studio.

How to create Splashscreen | Android Studio.