Hi, I am trying to add backgroung-image to body of a webpage. Its working on inline way but noy through css. I tried everything even searched on google. But I don't want where I am making mistake.

<!doctype HTML>
<link rel = "stylesheet" type = "text/css" href = "assets/stylesheet.css" />



And here is CSS:

body {
    background-image: url("images/p3.jpg");

I also tried:

    body {
        background: url(images/p3.jpg);

But not working!

Recommended Answers

Check this old, but stil relevant, article about file paths. That explains it.

Jump to Post

All 4 Replies

I asume your CSS is in that stylesheet.css, so then your path to that image should be like this.

body {
    background-image: url("../images/p3.jpg");
Member Avatar

Quick check in your console. If styleheet can't be found this will be stated in the console.

This code is working!

    body {
        background-image: url("../images/p3.jpg");

What was the problem on that codes which I sent? Can you tell me @gentlemedia.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.