Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why is my editor reporting that I have one extra table row element?

The assignment errors are saying that I need 5 table row elements in my table but supposedly I have 6. I’ve went through on zyBooks and Sublime text, I’m only seeing 5. Can anyone else see what’s going on and why it’s saying I have too many table row elements?

I’ve counted the elements over and over and over in the application itself and on Sublime Text.

<body>
  <table>
    <tr>
      <caption>Red Rocks, Colorado</caption>
      <th>Photo</th>
      <th>Date</th>
      <th>Description</th>
    </tr>
    <tr>
      <td>
        <img src="https://via.placeholder.com/50" alt="View from the top row; sitting area holds 9,525 people">
      </td>
      <td>Jan 16,2018</td>
      <td>View from the top row; sitting area holds 9,525 people</td>
    </tr>
    <tr>
      <td>
        <img src="https://via.placeholder.com/50" alt="Facing south from the top of the amphitheater">
      </td>
      <td>Feb 20, 2017</td>
      <td>Facing south from the top of the amphitheater</td>
    </tr>
    <tr>
      <td>
        <img src="https://via.placeholder.com/50" alt="Nearby red rocks sit 6,450 feet (1,970m) above sea level">
      </td>
      <td>Mar 30, 2019</td>
      <td>Nearby red rocks sit 6,450 feet (1,970m) above sea level</td>
    </tr>
    <tr>
      <td colspan="5">Copyright @ 2023 Zippy Photographers</td>
    </tr>
  </table>
</body>

I’m currently reformatting since zyBooks sucks at that. Hopefully that will help.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You’ve misapplied the caption element.

If included, the <caption> element must be the first child of its parent <table> element.

By including it in a row, you force the browser to guess at what valid HTML you intended. It’s wrapping the caption in a separate tbody element (which your table lacks). Your assignment analyzer may be interpreting it as another row.

Be sure to peruse the docs for every element you use so you understand its purpose and its constraints. They’re not to be used arbitrarily.

Then, look into how to examine your page with your browser’s document inspector. It’s an invaluable tool for troubleshooting and would’ve given you hints to the reason for this problem.

<body>
  <table>
    <tr>
      <caption>Row 1</caption>
      <th>Row 2</th>
      <th>Date</th>
      <th>Description</th>
    </tr>

    <tr>
      <td>
        Row 3
      </td>
      <td>Jan 16,2018</td>
      <td>View from the top row; sitting area holds 9,525 people</td>
    </tr>

    <tr>
      <td>
        Row 4
      </td>
      <td>Feb 20, 2017</td>
      <td>Facing south from the top of the amphitheater</td>
    </tr>

    <tr>
      <td>
        Row 5
      </td>
      <td>Mar 30, 2019</td>
      <td>Nearby red rocks sit 6,450 feet (1,970m) above sea level</td>
    </tr>

    <tr>
      <td colspan="5">Row 6</td>
    </tr>
  </table>
</body>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading