Ask coding questions

← Back to all posts
How do I add a background image to my website?

How do I add a background image to my website

Answered by qualladoom (366) [earned 5 cycles]
View Answer
qualladoom (366)

As I understand you want to have a fullsize background image. This can be done via

body, html {
  height: 100%;

.bg {
  /* The image used */
  background-image: url("img.jpg");

  /* Full height */
  height: 100%;

  /* Center and scale the image nicely */
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
katyadee (1288)

@enigma512 Thanks Enigma! We appreciate all your contributions :)

katyadee (1288)

Hey @RyanBeebe, I edited your post so your question is in the subject line. That way users who might have an answer can find it more easily :)