Learn Basic CSS by Building a Cafe Menu - Step 26

what is the sytax for a margin?

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Cafe Menu</title>
    <link href="styles.css" rel="stylesheet"/>
  </head>
  <body>
    <div>
      <header>
        <h1>CAMPER CAFE</h1>
        <p>Est. 2020</p>
      </header>
      <main>
        <section>
          <h2>Coffee</h2>
        </section>
      </main>
    </div>
  </body>
</html>
/* file: styles.css */
body {
  /*
  background-color: burlywood;
  */
}

h1, h2, p {
  text-align: center;
}
margin-left=auto { } div {
  width: 80%;
  background-color: burlywood;
}

Your browser information:

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

Challenge: Learn Basic CSS by Building a Cafe Menu - Step 26

Link to the challenge:

I think this exercise wants a margin-left and margin-right?

So that is just the usual syntax

property: value;

h1, h2, p {
  text-align: center;
}
margin-left=auto { } div {
  width: 80%;
  background-color: burlywood;
}

If you look at your above code, notice the first block’s format:

  • you have a few html elements which opens the bracers to receive styling (text-align) properties / values. You can do this same format with just 1 element if you want – the <div> in the next block could be done the same way.
  • the problem is in the second styling block- you have called on a property without first specifying the element you want to style. You would want something more like this: div { margin-left: auto; }
  • You want to make sure anything that changes appearance of an existing element is called on inside the curly bracers which follow the element you are styling.

different example:

p {
 margin-left: auto;
}
1 Like