通过编写咖啡店菜单学习基础 CSS - Step 28

告诉我们发生了什么:
在此详细描述你的问题。

How do I add the class attribute to the start tag of a div element and set its value to menu?

  **你目前的代码**
/* 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;
}

.menu {
width: 80%;
background-color: burlywood;
margin-left: auto;
margin-right: auto;
}

挑战: 通过编写咖啡店菜单学习基础 CSS - Step 28

挑战的链接:

class is an attribute. Attributes are added to the opening-tag.

Example for an a-tag:

<a class = "example"></a>

you can do such to your div elements opening-tag.

<div></div>

要div 闭合

1 Like

已经解决了,谢谢您 正确语法是:

:rofl:

哈哈 是这样写的 ![截屏2022-08-09 17.55.47|556x52](upload://tdFJ9Qu050rNs3b81Ad6TvA4Ib.png)

截屏2022-08-09 17.55.47
:laughing: