Build a Book Inventory App - Build a Book Inventory App

Tell us what’s happening:

I have tried various things and I cannot get 46-51.

• Failed:46. You should have an attribute selector to target the first descendant of span elements that have the word one as a part of their class value.
• Failed:47. You should use an attribute selector to target the first descendant of span elements that have the word one as a part of their class value and set its background-image property to use a linear-gradient.
• Failed:48. You should have an attribute selector to target the first two de

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>Book Inventory</title>
  <link rel="stylesheet" href="styles.css">
</head>

<body>
<h1>Book Inventory</h1>
 <table>
    <thead>
      <tr>
        <th>Title</th>
        <th>Author</th>
        <th>Category</th>
        <th>Status</th>
        <th>Rate</th>
      </tr>
    </thead>
      <tbody>
        <tr class="read">
          <td>Title 1</td>
          <td>Who wrote the book</td>
          <td>Comedy</td>
          <td><span class="status">Read</span></td>
          <td><span class="rate one"><span></span><span></span><span></span></span></td>
        </tr>
        <tr class="to-read">
          <td>Title 2</td>
          <td>I wrote the book</td>
          <td>Romance</td>
          <td><span class="status">To Read</span></td>
          <td><span class="rate"><span></span><span></span><span></span></span></td>
        </tr>
        <tr class="in-progress">
          <td>Title 3</td>
          <td>They wrote the book</td>
          <td>Suspence</td>
          <td><span class="status">In Progress</span></td>
          <td><span class="rate"><span></span><span></span><span></span></span></td>
       </tr>
        <tr class="read">
          <td>Title 4</td>
          <td>She wrote the book</td>
          <td>Western</td>
          <td><span class="status">Read</span></td>
          <td><span class="rate two"><span></span><span></span><span></span></span></td>
        </tr>
        <tr class="to-read">
          <td>Title 5</td>
          <td>He wrote the book</td>
          <td>Romcom</td>
          <td><span class="status">To Read</span></td>
          <td><span class="rate"><span></span><span></span><span></span></span></td>
        </tr>
      </tbody>
    <tfoot>
     
    </tfoot>
  </table>

</body>

</html>
/* file: styles.css */
tr[class="read"] {
  background: linear-gradient(red, white); 
}

tr[class="to-read"] {
  background: linear-gradient(green, white);
}

tr[class="in-progress"] {
background: linear-gradient( blue, pink, white);
}

span {
  display: inline-block;
}

tr[class="to-read"] span[class="status"] {
  border: 3px solid green;
  background-image: url(paper.gif);
}

tr[class="read"] span[class="status"] {
  border: 3px solid red;
  background-image: url(paper.gif);
}

tr[class="in-progress"] span[class="status"] {
  border: 3px solid blue;
  background-image: url(paper.gif);
}

span[class="status"], span[class^="rate"]  {
  border: 3px solid blue;
  border-radius: 5px;
  margin: 10px;
  padding: 5px;
  height: 10px;
  width: 10px;
  background-color: white;
}
tr span[class="status"] {
  border: 3px solid blue;
  border-radius: 5px;
  margin: 5px;
  height: 50px;
  width: 50px;
  font-size: 15px;
  background-color: white;
}
tr span[class="read"] {
  border: 3px solid white;
  border-radius: 5px;
  margin: 5px;
  height: 50px;
  width: 50px;
  font-size: 15px;
  background-color: white;
}
span[class^="rate"] > span {
  border: 1px solid white;
  border-radius: 5px;
  margin: 2px;
  padding: 2px;
  height: 10px;
  width: 10px;
  background-color: rgb(236, 163, 163);
}

span[class="one"]:first-child {
  background-image: linear-gradient(to right skyblue, pink); 
}

span[class="two"] > :nth-child(-n+2) {
  background-image: linear-gradient(to right white, red); 
}

span[class="three"]  span {
  background-image: linear-gradient(to right blue, red); 
}

Your browser information:

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

Challenge Information:

Build a Book Inventory App - Build a Book Inventory App

Hey there,

Please update the message to include your code. The code was too long to be automatically inserted by the help button.

When you enter a code, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

which part of your code do you think satisfies this?

1 Like

Look at your HTML. The span with a class of “one” also has another class. Your selector needs to handle that.

1 Like

Isn’t this the part of the code that satisies this: span[class=“one”]:first-child

no, because that one matches only element that have only the one class not multiple classes like it’s the case for the elements you need to select

I updated my code to include the other class as well, but it is still not working:

span[class=“status one”]:first-child {
background-image: linear-gradient(to right skyblue, pink);
}

I don’t understand what I’m missing.

you need to use a modyfier that changes how the attribute is matched, you don’t need to change the value

1 Like

Take a look at this MDN reference about attribute selectors. You should find your answer there. Remember, you’re looking for a word included in a class list.

Attribute selectors - CSS | MDN

1 Like

Thank you both! Wow that just burnt out all my brain cells. :rofl:

1 Like