How do i change the background color of my website with HTML

98 Views Asked by At

Help me,i need to change the color of the background of my website and i dont know how, I still haven't tried doing that because i dont know how. I have only coded these lines:

<!DOCTYPE html>
<html>
    <head>
       <title>My first creations with coding!</title>
    </head>
   <body>
   <h1>My first creations with coding!</h1>  
     <br>
     <p>>like pro</p>


    
     
      </body>
</html>

3

There are 3 best solutions below

1
kamst01 On BEST ANSWER

You need a Cascading Style Sheet or .css file my dude. You can read more about that here.

Without reading that doc & overloading you with an insane amount of information... how can you set it up & get going?

  1. In your website folder directory, add a new folder named assets
  2. Within this new assets folder, create a new file named style.css
  3. Attach this new style.css to your html file, within your head element. Using the following code :
      <!DOCTYPE html> 
        <html>
          <head>
            <title>My first creations with coding!</title>
            <link src="/assets/style.css" rel="stylesheet"/>
          </head>
    
  4. Save your 'html' file.
  5. Open style.css
  6. Add the following code :
      body {
         background-color: black; /* change the 'black' color here ONLY */
      }
    
    List of color keywords if you scroll down.
  7. Save the css file.
  8. Refresh your browser.

Now just repeat steps 5-8 to change the background of your site.

0
Gaurav On

<!DOCTYPE html>
<html>
    <head>
       <title>My first creations with coding!</title>
    </head>
   <body style="background-color:powderblue;">
   <h1>My first creations with coding!</h1>  
     <br>
     <p>>like pro</p>


    
     
      </body>
</html>

0
pr - On

To change the background color, you need another coding language called CSS (cascading style sheets). You can implement it with a <style> </style> tag, and add CSS there, or add a separate file and link it like this:

<link rel="stylesheet" href="YOUR FILE HERE">

You can learn more about CSS here.