Tables: rowspan MCQs Quiz | Class 10

This quiz covers Tables: rowspan MCQs for Class X Computer Applications (Code 165), specifically focusing on Unit 2: HTML and the concept of row spanning cells. Test your knowledge on how to merge cells vertically in HTML tables. After attempting all 10 multiple-choice questions, submit your answers to see your score and review correct solutions. You can also download a personalized PDF answer sheet for future reference.

Understanding rowspan in HTML Tables

HTML tables are fundamental for presenting data in a structured, grid-like format on web pages. While basic tables consist of simple rows and columns, the rowspan and colspan attributes allow for more complex layouts by merging cells, similar to how cells are merged in spreadsheet applications like Microsoft Excel or Google Sheets. This educational content focuses on the rowspan attribute.

What is rowspan?

The rowspan attribute in HTML is used to merge cells vertically. When you apply rowspan to a <td> (table data) or <th> (table header) element, it instructs the browser to make that cell extend downwards, occupying the space of multiple rows. This is particularly useful when you have content that logically spans across several rows, such as a category label for multiple items.

Syntax:

The rowspan attribute takes an integer value, which specifies how many rows the cell should span.

<td rowspan="N">Content</td>

Where N is the number of rows the cell will occupy.

Key Concepts and Usage:

  1. Vertical Merging: rowspan merges cells along the vertical axis, combining cells from the current row with cells from subsequent rows.
  2. Used with <td> and <th>: This attribute can be applied to both <td> (table data cell) and <th> (table header cell) elements.
  3. Value Interpretation:
    • rowspan="1": This is the default behavior. The cell spans only one row. You typically don’t need to specify rowspan="1".
    • rowspan="N" (where N > 1): The cell spans N rows, including the current row.
    • rowspan="0": This special value makes the cell span all the way to the end of the table section (<thead>, <tbody>, or <tfoot>) in which it is defined. While technically valid, it’s less commonly used than specific numeric values for predictability.
  4. Omitting Cells in Subsequent Rows: This is the most crucial aspect of using rowspan. If a cell in <trA> has rowspan="3", it means this cell will extend into the positions that would normally be occupied by cells in <trB> and <trC>. Therefore, you must omit the corresponding <td> or <th> elements from <trB> and <trC> at the position where the spanned cell from <trA> is extending. Failing to do so will result in an incorrectly structured table, often causing cells to shift or overlap.
  5. Maintaining Rectangular Structure: The goal when using rowspan (and colspan) is to always ensure that the total number of “slots” for cells in each conceptual row remains consistent, even if some cells are visually larger due to spanning.

Example Table with rowspan:

Imagine a table listing subjects and their topics. A “Science” category might span multiple topics.

Category Topic Status
Science Physics Completed
Chemistry In Progress
Mathematics Algebra Completed

Why use rowspan?

  • Improved Readability: Groups related information visually, making complex tables easier to understand.
  • Reduced Redundancy: Avoids repeating the same information in multiple rows.
  • Aesthetic Layouts: Helps create more visually appealing and structured table designs.

Quick Revision Checklist:

  • rowspan merges cells vertically.
  • Used on <td> and <th> tags.
  • Value N means spanning N rows.
  • rowspan="0" spans to the end of the table section.
  • Crucially, omit cells from subsequent rows that are being spanned into.
  • Helps organize and present data efficiently.

Practice Questions:

  1. What is the minimum value that rowspan can take to actually span multiple rows?
    1. 0
    2. 1
    3. 2
    4. Any positive integer
  2. If a <td> has rowspan="4", which subsequent <tr> elements should have a reduced number of <td> cells?
    1. The next <tr> only.
    2. The next two <tr> elements.
    3. The next three <tr> elements.
    4. All subsequent <tr> elements in the table.
  3. Which of the following attributes would you use to merge cells horizontally?
    1. rowspan
    2. spanrows
    3. colspan
    4. cellspan
  4. A table with <thead>, <tbody>, and <tfoot> sections uses rowspan="0" in a <td> inside <tbody>. Up to which point will this cell span?
    1. Until the end of the <thead>.
    2. Until the end of the entire <table>.
    3. Until the end of the <tbody>.
    4. It will be ignored, defaulting to rowspan="1".
  5. What happens if you use rowspan on a cell but do not omit the corresponding cells in the following rows?
    1. The rowspan attribute is ignored.
    2. The table will still render correctly, but with hidden cells.
    3. The table structure will break, leading to misaligned or overlapped cells.
    4. The browser will automatically adjust other cells to compensate.

Author

  • CBSE Quiz Editorial Team

    Content created and reviewed by the CBSE Quiz Editorial Team based on the latest NCERT textbooks and CBSE syllabus. Our goal is to help students practice concepts clearly, confidently, and exam-ready through well-structured MCQs and revision content.