Search code examples
htmlhtml4

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


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>


Solution

  • 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.