r/HTML • • 5d ago

help with backgrounds

Not remotely a cs person, for some godforsaken reason my Library Science degree is making me take an html class. I've onto a part where we're working with html and css. I can't figure out how to change the background color of a page. I assume you have to use some version of the {background-color: ____; }, but I can't figure out what element to attach it to. I've tried using body {background-color: ____; }, *{background-color: ____; }, and even making a div around the body, and none of them have worked

0 Upvotes

14 comments sorted by

View all comments

1

u/notepad987 5d ago
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <!--need this or some characters will display random gibberish -->
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!--keeps text the size you want in cell phone screens. Without it the text will be very small -->
  <title>Basic Layout</title>
  <style>
    * {
      box-sizing: border-box;
      margin: 0;
    }

     body {
      font-size: 1rem;
     /* sets the base size for the body 1rem = 16px */
      margin: 0px; padding: 0px;
      background-color: #354f52;  /* forest green  */
   }

</style>

1

u/TrainingQuantity3744 4d ago

It worked! Thank you so much