Learn Responsive Web Design by Building a Piano - Step 10

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**
/* file: index.html */
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>Piano</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="stylesheet" href="./styles.css">
</head>
<body>
  <div id="piano">
    <div class="keys">
      <div class="key"></div>
      <div class="key black--key"></div>
      <div class="key black--key"></div>
      <div class="key"></div>
      <div class="key black--key"></div>
      <div class="key black--key"></div>
      <div class="key black--key"></div>

      <div class="key"></div>
      <div class="key black--key"></div>
      <div class="key black--key"></div>
      <div class="key"></div>
      <div class="key black--key"></div>
      <div class="key black--key"></div>
      <div class="key black--key"></div>

      <div class="key"></div>
      <div class="key black--key"></div>
      <div class="key black--key"></div>
      <div class="key"></div>
      <div class="key black--key"></div>
      <div class="key black--key"></div>
      <div class="key black--key"></div>
    </div>
  </div>
</body>
</html>
/* file: styles.css */

*, ::bofore, ::after {
box-sizing: inherit;
}
  **Your browser information:**

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

Challenge: Learn Responsive Web Design by Building a Piano - Step 10

Link to the challenge:

hey there

you have a typo here

But why do you have to do this step at all? Doesn’t setting html selector apply the style to everything in the page?

html {
box-sizing: border-box;
}

*, *::before, *::after {
box-sizing: inherit;
}
← Shouldn’t the first styling of html { border-box} apply to everything? In addition, doesn’t the * { } styling apply to everything? So if you’re using the html { }, why would you also use the * { }? And if you’re using the * { } universal selector, why would you also have to specify pseudo stuff?

2 Likes

I believe * doesn’t include ::before and ::after psuedo elements so you have to include them so they apply. I am confused why the code isn’t simply put as

*, *::before, *::after {
box-sizing: border-box;
}

instead of includeing the extra code used in the example then adding inherit. Could someone explain?

html {
box-sizing: border-box;
}
*, *::before, *::after {
box-sizing: inherit;
}

Why would this above be preferrable to the simple code I wrote?

I am going to create a forum post about this question I want to understand this.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.