PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 3, 2022

[FIXED] Why is rowspan not working if i switch the order of the cells?

 August 03, 2022     html, html-table, layout     No comments   

Issue

I have a really simple example that is driving me crazy. Can someone explain why is this working

<table>
  <tr>
    <td>January</td>
    <td rowspan="2">$100</td>
  </tr>
  <tr>
    <td>February</td>
  </tr>
</table>

While this isn't?

<table>
  <tr>
    <td>January</td>
  </tr>
  <tr>
    <td>February</td>
    <td rowspan="2">$100</td>
  </tr>
</table>

Solution

Perhaps the easiest way to understand what's happening here is to add a third row.

Firstly, we can have a table where the $100 spans January and February, but not March:

<table>
  <tr>
    <td>January</td>
    <td rowspan="2">$100</td>
  </tr>
  <tr>
    <td>February</td>
  </tr>
  <tr>
    <td>March</td>
  </tr>
</table>

Then, we can have one that spans February and March, but not January:

<table>
  <tr>
    <td>January</td>
  </tr>
  <tr>
    <td>February</td>
    <td rowspan="2">$100</td>
  </tr>
  <tr>
    <td>March</td>
  </tr>
</table>

As you can see, the value always spans down the table, not up it; similarly, a colspan spans right, not left. In your second example in the question, there is no row below February for the value to span down to, so the attribute has no effect.



Answered By - IMSoP
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing