Why is {text-align:center;} written like this:

Hey, I’m new to coding, and was wondering why this code is written like this:

h1 {
text-align: center;
}

instead of just: h1 {text-align: center;}

Just curious because the second seems a lot more clear to me (without taking 3 lines). But I read online most people write it like the first example, so is there a reason for it?

  **Your code so far**
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <title>Cafe Menu</title>
  <style>
    h1 {
      text-align: center;
    }
    h2 {
      text-align: center;
    }
    p {
      text-align: center;
    }
  </style>
</head>
<body>
  <header>
    <h1>CAMPER CAFE</h1>
    <p>Est. 2020</p>
  </header>
  <main>
    <section>
      <h2>Coffee</h2>
    </section>
  </main>
</body>
<html>
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36

Challenge: Step 14

Link to the challenge:

Hi, both styles are okey, but when you have more than one atribute is easiest to read

 {
  display: inline-block;
  box-sizing: border-box;
  margin: 3px;
  border-radius: 6px;
  box-shadow: 3px 3px 12px 3px #454545; 
  padding-top: 15px;
  position: relative;
  width: 100px;
  height: 80px;
  background-color: grey;
}

than

 { display: inline-block;box-sizing: border-box;margin: 3px;  border-radius: 6px;  box-shadow: 3px 3px 12px 3px #454545;   padding-top: 15px;position: relative;width: 100px; height: 80px; background-color: grey;}
1 Like

Ah yea, that explains it! Thank you!