Make uneven table layout - html

When I use <table> with <tr> and <td> I always get NxN tables and not what I want.
For example:
<table border = "1">
<tr> <td> Do you love peanuts? This is a very important question. </td> </tr>
<tr> <td> Yes, I do. </td> <td> No, I don't. </td> </tr>
</table>
And yet, it looks like a 2x2 as one there is a blank square created over the page.
An example is here.
How can I make the first row (with the one element) spread the same as the one with two elements. I'm not talking about minimizing number of lines (in the text) or whatever, I mean just stretching it up to there.

You can solve this using the attribute colspan on the td tag:
<table border = "1">
<tr>
<td colspan="2">
Do you love peanuts? This is a very important question.
</td>
</tr>
<tr>
<td>
Yes, I do.
</td>
<td>
No, I don't.
</td>
</tr>
</table>
Check this link

<html>
<head>
</head>
<body>
<table>
<tr>
<td>
<table border="1">
<tr>
<td width="250px">Do you love peanuts? This is a very important question.</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<td width="250px">
Yes, I do.
</td>
<td>
No, I don't.
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

Related

Setting <td> width throwing off table display?

I'm totally stuck trying to figure out why setting a td width attribute in the following table is throwing off the display.
<table style="width:100%;">
<tbody>
<tr>
<td colspan="4">
<big><big><b>Investments By Bruce Wayne</b></big></big>
</td>
</tr>
<tr>
<td style="width:20%;"><b><u>Date</u></b></td>
<td style="width:20%;"><b><u>Invested</u></b></td>
<td style="width:30%;"><b><u>Company (and Round)</u></b></td>
<td style="width:30%;"><b><u>SPV</u></b></td>
</tr>
</tbody>
</table>
The above is rendered with the word "Invested" outside of the table entirely (see screenshot).
Any thoughts on why this might be happening? Thanks in advance!
<table style="width:100%;">
<tbody>
<tr>
<td colspan="4">
<big><big><b>Investments By Bruce Wayne</b></big></big>
</td>
</tr>
<tr>
<td style="width:20%;"><b><u>Date</u></b></td>
<td style="width:20%;"><b><u>Invested</u></b></td>
<td style="width:30%;"><b><u>SPV</u></b></td>
<td style="width:30%;"><b><u>Company (and Round)</u></b></td>
</tr>
</tbody>
</table>
Problem:
All you have to do is to format your code. There is a NON-BREAKING-SPACE between td and style <td style (the one with the Investment text) that destroys the layout. To reproduce you can delete the whitespace and add the whitespace again.
Note:
You have to <big><big> there wrapped - this can be reduced to just one element.
<table style="width:100%">
<tbody>
<tr>
<td colspan="4">
<big><b>Investments By Bruce Wayne</b></big>
</td>
</tr>
<tr>
<td style="width:20%;"><b><u>Date</u></b></td>
<td style="width:20%;"><b><u>Invested</u></b></td>
<td style="width:30%;"><b><u>Company (and Round)</u></b></td>
<td style="width:30%;"><b><u>SPV</u></b></td>
</tr>
</tbody>
</table>

How to apply an ng-if (or other conditional) in multiple <td> elements while keeping it DRY

I want to display a number of <td> elements based on the same condition. I am currently doing that with multiple, identical, ng-if directives, as such:
<tbody>
<tr>
<td> Display unconditionally </td>
<td> Same here... (imagine more columns) </td>
...
<td ng-if='myCondition'> Display based on condition </td>
<td ng-if='myCondition'> And the same </td>
<td ng-if='myCondition'> for plenty of columns </td>
</tr>
</tbody>
While this works one can't help but notice all the repetition. Any ideas on how I could DRY that up?
Use ng-if-start and ng-if-end
<table>
<tr>
<td ng-if-start="false" >one</td>
<td>two</td>
<td ng-if-end >three</td></td>
<td>foure</td>
<td>five</td>
</tr>
</table>
Plunker

How do you skip a <td> tag in HTML

I want to know how do you skip a tag in HTML5.0. I mean literally, without CSS. Instead of an empty box, I want it to be filled in, not just blank. Any help would be appreciated
You can use colspan or rowspan.
<table>
<tr>
<td colspan="2">
Header
</td>
</tr>
<tr>
<td>
Text
</td>
<td>
Text
</td>
</tr>
<tr>
<td>
Text
</td>
<td>
Text
</td>
</tr>
</table>

What is the markup for this table?

Im really stuck making the markup for this kind of table I almost spend 2hrs reading the difference between rowspan and colspan. Im badly need help for this guys.
Thanks
Code for first two rows:
<html>
<head>
<title>
</title>
</head>
<body>
<table border="2">
<tr>
<td rowspan="2">Diversifier Portfolio PDF</td>
<td>Investment Management</td>
<td>0.30%</td>
<td rowspan="2">0.40%</td>
</tr>
<tr>
<td>Administration</td>
<td>0.10%</td>
</tr>
</table>
</body>
</html>
Edit: I was too slow :'(
Repeat the same for three times
<table border="1">
<tr>
<td rowspan="2">
Divers
</td>
<td>
Invest
</td>
<td>
0.30%
</td>
<td rowspan="2">
0.40%
</td>
</tr>
<tr>
<td>
Invest
</td>
<td>
0.10%
</td>
</tr>
</table>

How to do Alignment setting of table within a table?

I have to create a simple table within a table. i am using following html code for making as simple page. please copy and paste it to file for understand the problem correctly.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<BODY>
<table border=1>
<tr>
<td>
<table>
<tr>
<td>thid entry should be on top</td>
</tr>
<tr>
<td>why this comes in middle</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>entry1</td>
</tr>
<tr>
<td>entry2</td>
</tr>
<tr>
<td>entry3</td>
</tr>
<tr>
<td>entry4</td>
</tr>
<tr>
<td>entry5</td>
</tr>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>
The main problem is in my right side part of table I have some searched information, and left side some refine search panel. so when my page comes, my refine search window comes exact middle. i want my left part of table is to aligned on table, where my start.
Please help me to resolve this.
valign="top" in the correct column would be a simple solution to your prob.
like:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<BODY>
<table border=1>
<tr>
<td valign="top">
<table>
<tr>
<td>thid entry should be on top</td>
</tr>
<tr>
<td>why this comes in middle</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>entry1</td>
</tr>
<tr>
<td>entry2</td>
</tr>
<tr>
<td>entry3</td>
</tr>
<tr>
<td>entry4</td>
</tr>
<tr>
<td>entry5</td>
</tr>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>
edit:
style="vertical-align:top;" if you use css