1

I require some help. My friend sent me an HTML document and he asked me to change the background. Now I'm new to HTML and all this but changing the background should be easy but I can't find it anywhere in the HTML doc or the CSS. Any help?

3
  • 2
    need to see code mate. Commented May 9, 2020 at 18:32
  • 1
    Use the css background-color property. This should be easy to find if you do some research yourself, for example by googling 'CSS background', which gets you many results. If on the other hand you've tried this already and it didn't work, we need to see your code to solve the problem. Commented May 9, 2020 at 18:35
  • @BalvantAhir added the code Commented May 9, 2020 at 21:19

6 Answers 6

1

Just create a new css for example for body like this if you want it to be black:

     body {
     background: #000000;
     }

That should work.

Sign up to request clarification or add additional context in comments.

2 Comments

Its an image and I need to change the image out for a new one
Then like this: background: #000 url(/images/background.png);
1

div{
   background-image: url("https://homepages.cae.wisc.edu/~ece533/images/tulips.png");
   height:100px;
}
<div></div>

3 Comments

worked but only for 2 bits of the section so I don't know if there is an image in front but i cant find it so?
@BenHoward Please indicate your code to your question above. So that we can help you here. Thanks
1

You can change the background by using background-color or background-image as follows:

<div style="background-color: red" >
This div has a background-color of red
</div>

Comments

1

The HTML file contains 2 main sections - <head>, <body>.

Head specifies attributes like page title, language, links to stylesheets (css / designs).

'Background' can be applied to any part within the <body> section of the HTML file (including body).

Background can be applied in 2 ways -

  1. A colour - Using style="background-color: color-code;"
  2. An image - Using style="background-image: url('img_girl.jpg')"

Here is an example of background being applied:

Approach 1: Background colour:

<!DOCTYPE html>
<html>
  <head>
    <title>My Website</title>
  </head>
  <body style="background-color: #e6f2ff;">
    <div class="my-page">
      <h1>-- Heading here --</h2>
      <p>-- Description here -- </p>
    </div>
  </body>
</html>

Approach 2: Background image:

<!DOCTYPE html>
<html>
  <head>
    <title>My Website</title>
  </head>
  <body style="background-image: url("/paper.gif");">
    <div class="my-page">
      <h1>-- Heading here --</h2>
      <p>-- Description here -- </p>
    </div>
  </body>
</html>

Note:
The background color / image can be applied to any element inside body, I.E., to div / h1 / p ...

More information:

https://www.w3schools.com/cssref/pr_background-image.asp

https://www.w3schools.com/html/html_images_background.asp

Comments

1

Add a style for header in your CSS file :

.header {
  background: "#000000"
}

Comments

0

The background image can be inserted in the page using the below within body tag or by using CSS: < div style="background-image:url('[image url]');>

Also, this website contain good information to go through : https://www.wikihow.com/Set-a-Background-Image-in-HTML

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.