Build a Book Inventory App - Build a Book Inventory App

Tell us what’s happening:

Please help on below code

  1. You should have an h1 element with the text Book Inventory.
    Passed:2. You should have only one h1 element.
    Passed:3. You should have a table element.
    Passed:4. You should have one thead element and one tbody element inside table.
    Passed:5. Inside the thead there should be one tr with 5 th elements.
    Passed:6. Your first column should have the text Title as the heading.
    Passed:7. Your second column should have the text Author as the heading.
    Passed:8. Your third column

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Book Inventory</title>
<style>
/* ===== General ===== */
body {
  font-family: Arial, sans-serif;
  padding: 40px;
  background: #f5f7fa;
}

h1 {
  text-align: center;
}

/* ===== Table ===== */
table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th, td {
  padding: 10px;
  border: 1px solid #ccc;
  text-align: left;
}

/* ===== Row Gradients ===== */
tr[class="read"] {
  background-image: linear-gradient(to right, #d4edda, #ffffff);
}
tr[class="to-read"] {
  background-image: linear-gradient(to right, #fff3cd, #ffffff);
}
tr[class="in-progress"] {
  background-image: linear-gradient(to right, #cce5ff, #ffffff);
}

/* ===== Spans inline-block ===== */
span {
  display: inline-block;
}

/* ===== Status styling ===== */
tr[class="to-read"] span[class="status"] {
  border: 1px solid orange;
  background-image: linear-gradient(to right, #ffe0b2, #ffcc80);
}
tr[class="read"] span[class="status"] {
  border: 1px solid green;
  background-image: linear-gradient(to right, #a5d6a7, #81c784);
}
tr[class="in-progress"] span[class="status"] {
  border: 1px solid blue;
  background-image: linear-gradient(to right, #90caf9, #64b5f6);
}

/* ===== Status + Rate sizing ===== */
span[class="status"],
span[class^="rate"] {
  height: 25px;
  width: 100px;
  padding: 4px;
  text-align: center;
}

/* ===== Rate children styling ===== */
span[class^="rate"] > span {
  border: 1px solid #888;
  border-radius: 4px;
  margin: 2px;
  height: 15px;
  width: 15px;
  background-color: #eee;
}

/* ===== Rating fills (tests 48–53) ===== */

/* ONE → first child only */
span[class*="one"] > span:first-child {
  background-image: linear-gradient(to top, green, lightgreen);
}

/* TWO → first two children */
span[class*="two"] > span:first-child,
span[class*="two"] > span:nth-child(2) {
  background-image: linear-gradient(to top, blue, lightblue);
}

/* THREE → all children */
span[class*="three"] > span {
  background-image: linear-gradient(to top, red, salmon);
}
</style>
</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>The Alchemist</td>
      <td>Paulo Coelho</td>
      <td>Fiction</td>
      <td><span class="status">Read</span></td>
      <td><span class="rate three"><span></span><span></span><span></span></span></td>
    </tr>
    <tr class="to-read">
      <td>Atomic Habits</td>
      <td>James Clear</td>
      <td>Self-help</td>
      <td><span class="status">To Read</span></td>
      <td><span class="rate one"><span></span><span></span><span></span></span></td>
    </tr>
    <tr class="in-progress">
      <td>Deep Work</td>
      <td>Cal Newport</td>
      <td>Productivity</td>
      <td><span class="status">In Progress</span></td>
      <td><span class="rate two"><span></span><span></span><span></span></span></td>
    </tr>
    <tr class="read">
      <td>1984</td>
      <td>George Orwell</td>
      <td>Dystopian</td>
      <td><span class="status">Read</span></td>
      <td><span class="rate two"><span></span><span></span><span></span></span></td>

/* file: styles.css */

Your browser information:

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

Challenge Information:

Build a Book Inventory App - Build a Book Inventory App

hello @Amarchaudhari welcome to the forum!

When you use this, it will also select a span having class=”someone”, can you think of some other selector instead of *?

  • 1. You should have an h1 element with the text Book Inventory.

  • Passed:2. You should have only one h1 element.

  • Passed:3. You should have a table element.

  • Passed:4. You should have one thead element and one tbody element inside table.

  • Passed:5. Inside the thead there should be one tr with 5 th elements.

  • Passed:6. Your first column should have the text Title as the heading.

  • Passed:7. Your second column should have the text Author as the heading.

  • Passed:8. Your third column should have the text Category as the heading.

  • Passed:9. Your fourth column should have the text Status as the heading.

  • Passed:10. Your fifth column should have the text Rate as the heading.

  • Passed:11. Your table should have at least four rows.

  • Passed:12. Each row should always have 5 columns.

  • Passed:13. Each table row except the heading row should have either the class read, to-read, or in-progress.

  • Passed:14. td elements of the Status column should contain a span element.

  • Passed:15. Each span element of the Status column should have the class of status.

  • Passed:16. Each .status element should have the text Read, To Read, or In Progress, depending on the class of its row.

  • Passed:17. td elements of the Rate column should contain a span element.

  • Passed:18. Each span element which is a direct child of a td element of the Rate column should have the class of rate as the first class.

  • Passed:19. Each .rate element should contain three empty span elements.

  • Passed:20. .rate elements placed inside .read rows should have an additional class after the rate class with the value of either one, two, or three, depending on the personal rate.

  • Passed:21. You should have an attribute selector to target rows that have the class of read.

  • Passed:22. You should use an attribute selector to target rows that have the class of read and set their background-image property to a linear gradient of your choice.

  • Passed:23. You should have an attribute selector to target rows that have the class of to-read.

  • Passed:24. You should use an attribute selector to target rows that have the class of to-read and set their background-image property to a linear gradient of your choice.

  • Passed:25. You should have an attribute selector to target rows that have the class of in-progress.

  • Passed:26. You should use an attribute selector to target rows that have the class of in-progress and set their background-image property to a linear gradient of your choice.

  • Passed:27. You should set the display property of each span element to inline-block.

  • Passed:28. You should have an attribute selector to target the span elements with the class of status that are descendants of tr elements with the class of to-read.

  • Passed:29. You should use an attribute selector to target the span elements with the class of status that are descendants of tr elements with the class of to-read and set their border property.

  • Passed:30. You should use an attribute selector to target the span elements with the class of status that are descendants of tr elements with the class of to-read and set their background-image property.

  • Passed:31. You should have an attribute selector to target the span elements with the class of status that are descendants of tr elements with the class of read.

  • Passed:32. You should use an attribute selector to target the span elements with the class of status that are descendants of tr elements with the class of read and set their border property.

  • Passed:33. You should use an attribute selector to target the span elements with the class of status that are descendants of tr elements with the class of read and set their background-image property.

  • Passed:34. You should have an attribute selector to target the span elements with the class of status that are descendants of tr elements with the class of in-progress.

  • Passed:35. You should use an attribute selector to target the span elements with the class of status that are descendants of tr elements with the class of in-progress and set their border property.

  • Passed:36. You should use an attribute selector to target the span elements with the class of status that are descendants of tr elements with the class of in-progress and set their background-image property.

  • Passed:37. You should have an attribute selector to target the span elements with the class of status and the span elements with the class value starting with rate.

  • Passed:38. You should use an attribute selector to target the span elements with the class of status and the span elements with the class value starting with rate and set their height property.

  • Passed:39. You should use an attribute selector to target the span elements with the class of status and the span elements with the class value starting with rate and set their width property.

  • Passed:40. You should use an attribute selector to target the span elements with the class of status and the span elements with the class value starting with rate and set their padding property.

  • Passed:41. You should have an attribute selector to target the span elements which are direct children of span elements with the class value starting with rate.

  • Passed:42. You should use an attribute selector to target the span elements which are direct children of span elements with the class value starting with rate and set their border property.

  • Passed:43. You should use an attribute selector to target the span elements which are direct children of span elements with the class value starting with rate and set their border-radius property.

  • Passed:44. You should use an attribute selector to target the span elements which are direct children of span elements with the class value starting with rate and set their margin property.

  • Passed:45. You should use an attribute selector to target the span elements which are direct children of span elements with the class value starting with rate and set their height property.

  • Passed:46. You should use an attribute selector to target the span elements which are direct children of span elements with the class value starting with rate and set their width property.

  • Passed:47. You should use an attribute selector to target the span elements which are direct children of span elements with the class value starting with rate and set their background-color property.

  • Failed:48. 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:49. 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:50. You should have an attribute selector to target the first two descendants of span elements that have the word two as a part of their class value.

  • Failed:51. You should use an attribute selector to target the first two descendants of span elements that have the word two as a part of their class value and set their background-image property to use a linear-gradient.

  • Failed:52. You should have an attribute selector to target the span elements that are descendants of span elements that have the word three as a part of their class value.

  • Failed:53. You should use an attribute selector to target the span elements that are descendants of span elements that have the word three as a part of their class value and set their background-image property to use a linear-gradient.

do you need additional help? please use your own words, do not copy all the tests

Tell us what’s happening:

  1. 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:49. 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:50. You should have an attribute selector to target the first two descendants of span elements that have the word two as a part of the

Your code so far

<!-- file: index.html -->
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Book Inventory</title>
<style>
/* ===== General ===== */
body {
  font-family: Arial, sans-serif;
  padding: 40px;
  background: #f5f7fa;
}

h1 {
  text-align: center;
}

/* ===== Table ===== */
table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th, td {
  padding: 10px;
  border: 1px solid #ccc;
  text-align: left;
}

/* ===== Row Gradients ===== */
tr[class="read"] {
  background-image: linear-gradient(to right, #d4edda, #ffffff);
}
tr[class="to-read"] {
  background-image: linear-gradient(to right, #fff3cd, #ffffff);
}
tr[class="in-progress"] {
  background-image: linear-gradient(to right, #cce5ff, #ffffff);
}

/* ===== Spans inline-block ===== */
span {
  display: inline-block;
}

/* ===== Status styling ===== */
tr[class="to-read"] span[class="status"] {
  border: 1px solid orange;
  background-image: linear-gradient(to right, #ffe0b2, #ffcc80);
}
tr[class="read"] span[class="status"] {
  border: 1px solid green;
  background-image: linear-gradient(to right, #a5d6a7, #81c784);
}
tr[class="in-progress"] span[class="status"] {
  border: 1px solid blue;
  background-image: linear-gradient(to right, #90caf9, #64b5f6);
}

/* ===== Status + Rate sizing ===== */
span[class="status"],
span[class^="rate"] {
  height: 25px;
  width: 100px;
  padding: 4px;
  text-align: center;
}

/* ===== Rate children styling ===== */
span[class^="rate"] > span {
  border: 1px solid #888;
  border-radius: 4px;
  margin: 2px;
  height: 15px;
  width: 15px;
  background-color: #eee;
}

/* ===== Rating fills (tests 48–53) ===== */

/* ONE → first child only */
span[class*="one"] > span:first-child {
  background-image: linear-gradient(to top, green, lightgreen);
}

/* TWO → first two children */
span[class*="two"] > span:first-child,
span[class*="two"] > span:nth-child(2) {
  background-image: linear-gradient(to top, blue, lightblue);
}

/* THREE → all children */
span[class*="three"] > span {
  background-image: linear-gradient(to top, red, salmon);
}
</style>
</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>The Alchemist</td>
      <td>Paulo Coelho</td>
      <td>Fiction</td>
      <td><span class="status">Read</span></td>
      <td><span class="rate three"><span></span><span></span><span></span></span></td>
    </tr>
    <tr class="to-read">
      <td>Atomic Habits</td>
      <td>James Clear</td>
      <td>Self-help</td>
      <td><span class="status">To Read</span></td>
      <td><span class="rate one"><span></span><span></span><span></span></span></td>
    </tr>
    <tr class="in-progress">
      <td>Deep Work</td>
      <td>Cal Newport</td>
      <td>Productivity</td>
      <td><span class="status">In Progress</span></td>
      <td><span class="rate two"><span></span><span></span><span></span></span></td>
    </tr>
    <tr class="read">
      <td>1984</td>
      <td>George Orwell</td>
      <td>Dystopian</td>
      <td><span class="status">Read</span></td>
      <td><span class="rate two"><span></span><span></span><span></span></span></td>

/* file: styles.css */

Your browser information:

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

Challenge Information:

Build a Book Inventory App - Build a Book Inventory App

you have alredy received a suggestion about looking into *= and an alternative, do you have additional questions?

I have merged your two topics, please do not create multiple topics for the same challenge