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

Tuesday, July 26, 2022

[FIXED] How to convert 2 column HTML table to 3 column

 July 26, 2022     dreamweaver, html, html-table     No comments   

Issue

I'm very new to HTML. I have an HTML document that is built using a 2 column table. I am now needing to set up a row with 3 columns. From the research that I've done, it seems that I can't just add a column to 1 row, rather I need to work with a 3 column table and use colspan in the other rows to make things work. Is that correct?

I've tried adjusting the existing colspans from =2 to =3 and adding a new column to the desired row but to no avail. Can you tell me what is wrong with my approach or how to properly convert the existing 2 column table to a 3 column structure?

<table width="768" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #000000" >
    <tr>
        <td colspan="2" width="768" height="160" border="0" style="display:inline" /></td>
    </tr>
    <tr>
        <td colspan="2"></td>
    </tr>
    <tr>
        <td colspan="2"></td>
    </tr>
    <tr>
        <td colspan="2"></td>
    </tr>  
    <tr>
        <td colspan="2"></td>
    </tr>
    <tr>
        <td width="256"></td>
        <td width="256"></td>
        <td width="256"></td>
    </tr>
    <tr>
        <td colspan="2"></td>
    </tr>
    <tr>
        <td colspan="2"></td>
    </tr> 
    <tr>
        <td colspan="2"></td>
    </tr>
</table>

Solution

<table border="1">
    <tr> <!-- row with 3 columns -->
        <td>1x1</td>
        <td>1x2</td>
        <td>1x3</td>
    </tr>
    <tr> <!-- row with only 2 columns, where the second column is as wide as the second and third column, above -->
        <td>2x1</td>
        <td colspan="2">2x2</td>
    </tr>
</table>

This is how to get a table with N rows and 3 columns. Is it what you were asking for? It would be useful if you could paste some code!

See this page to learn more about colspan: http://www.w3schools.com/tags/att_td_colspan.asp

EDIT:

In your code you have written the table to display only 2 columns for every row. You have to add a <td> tag to display another column per row.



Answered By - AleVale94
Answer Checked By - David Marino (PHPFixing Volunteer)
  • 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