Border collapse causes mobile browsers to show unwanted borders - html-table

Consider the following table in html:
<table style="border-collapse:collapse">
<tr>
<td style="height:25px"></td>
<td style="width:150px;border:1px solid #aaa;"></td>
<td rowspan="4" style="width:10px;"></td>
<td style="width:150px;border:1px solid #aaa;"></td>
</tr>
<tr>
<td style="height:25px"></td>
<td></td>
<td></td>
</tr>
<tr>
<td style="height:25px"></td>
<td></td>
<td></td>
</tr>
</table>
This table renders just fine on every desktop web browser I've tried, but on the mobile web browsers I've tried (iOS: Safari and Chrome), the middle column extends the left and right borders to the bottom. It looks like this:
Is there any way to get around this without, ideally without changing border-collapse or the middle column's rowspan?

Related

Is <tbody> automatically defined in a table?

I'm a starter and I was trying some elements, as practice.
There's sth that i can't figure it out.I also have searched google but no answers found.
I wrote 2 tables, in the first one I used tbody to style the body of the table. But when I load the page, I see the style used in css for the tbody in the first table, has also effected the second table(without tbody tag) completely.Why is this happening?
Here is the code :
<table id="t1">
<caption>UFO Seen by People</caption>
<thead>
<tr>
<th>Name</th>
<th>City Name</th>
<th>Seen</th>
<th>Times seen</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="3">Jack</td>
<td>North Russia</td>
<td>2020-06-12</td>
<td>once</td>
</tr>
<tr>
<td>North Korea</td>
<td>2000-06-12</td>
<td>once</td>
</tr>
<tr>
<td>North Pole</td>
<td>1995-06-12</td>
<td>twice</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="4">Blah Blah Blah</td>
</tr>
</tfoot>
</table>
<table id="t2">
<caption>UFO Seen by People2</caption>
<colgroup>
<col span="2" style="text-align:right; background-color:yellow;">
<col style="background-color:cyan; background-image:url('baelen.jpg');">
</colgroup>
<tr>
<th>Name</th>
<th>City Name</th>
<th>Seen</th>
<th>Times seen</th>
</tr>
<tr>
<td rowspan="3">Dan</td>
<td>North Russia</td>
<td>2020-06-12</td>
<td>once</td>
</tr>
<tr>
<td>North Korea</td>
<td>2000-06-12</td>
<td>once</td>
</tr>
<tr>
<td>North Pole</td>
<td>1995-06-12</td>
<td>twice</td>
</tr>
</table>
And here is the css used :
#t1 { border:2px solid black; border-spacing:10pt; background-color:pink; width:100%;}
#t2 { border:2px solid rgb(20,20,20); border-collapse:collapse; width:100%;}
tbody { background-color:white; text-align:center; vertical-align:middle; font-size:20pt;}
That's really simple, that affect the second table cause you use tbody in css and not #t1 tbody, use correct selector if you want to affect only one element.
In addition I advise you not to use style on HTML and in CSS except in the case of manipulation in JavaScript. This will also allow you to better understand what does what, if you want to give a particular style to elements of your table assign their classes to your CSS.

How custom element can have multiple <tr> components

I want create a one <table> where multiple custom elements can have multiple <tr> components.
I tried using containerless, but element get rendered outside of <table>.
<table>
<thead>
<tr>
<th>Position</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<order-line repeat.for="line of lines" line.to-view="line" containerless></order-line>
</tbody>
</table>
And custom element looks like
<template>
<tr>
<td>${line.position}</td>
<td>${line.name}</td>
</tr>
<tr if.to-view="detailsVisible">
<td colspan="2">${line.complicatedDescription}</td>
</tr>
</template>
How I can get a table row with details as another <tr> element within one aurelia CustomElement?
This is a limitation of the html spec. A <table> element cannot contain elements other than <tbody>, <tr>, etc.
You can use as-element to overcome this limitation:
<tr as-element="order-line" repeat.for="line of lines" line.to-view="line" containerless></tr>
This tells the template compiler that this <tr> is in fact an order-line custom element and to process it as such. At the same time, it "fools" the browser into thinking that this is just an ordinary <tr>
<table> can contain multiple <tbody> elements, this will allow to wrap multiple <tr> elements inside custom element with <tbody>.
/* custom element */
<template>
<tbody>
<tr>
<td>${line.position}</td>
<td>${line.name}</td>
</tr>
<tr if.to-view="detailsVisible">
<td colspan="2">${line.complicatedDescription}</td>
</tr>
</tbody>
</template>
Use as custom element inside
<table>
<thead>
<tr>
<th>Position</th>
<th>Name</th>
</tr>
</thead>
<order-line repeat.for="line of lines" line.to-view="line"></order-line>
</table>

Selenium IDE and CKEditor

I want to cleanup some HTML in a database using CKEditor's cleanup process. I need it to use this exact cleanup algorithm for reasons that are beyond the scope of this question. Submitting an existing form works perfectly, however there are many rows in the table, making for a tiresome process if done manually.
The solution I came up with was to generate a Selenium IDE test case that simply loads the page then submits the form for each record in the database.
The problem is that when Selenium IDE saves the data it does not seem to apply CKEditor's HTML cleanup algorithm.
For example...
I have the following in my database (loaded into CKEditor) when the form is loaded:
<p>
Hello World
</p>
When I press save on the form, the following is the result in my database:
<p>Hello World</p>
When I run a Selenium IDE script to load the page and submit the form, however the HTML remains unchanged (the cleanup did not occur).
Here is an example of my selenium script for a single form:
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr>
<td rowspan="1" colspan="3">selenium ckeditor</td>
</tr>
</thead>
<tbody>
<tr>
<td>open</td>
<td>/form.php?id=1</td>
<td></td>
</tr>
<tr>
<td>fireEventAndWait</td>
<td>id=form</td>
<td>submit</td>
</tr>
</tbody>
</table>
It seems some JS event is not being triggered, but I am not sure which event it could be.
Pausing for a second after loading the page makes it work. I guess selenium was submitting before ckeditor kicked in.
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr>
<td rowspan="1" colspan="3">selenium ckeditor</td>
</tr>
</thead>
<tbody>
<tr>
<td>open</td>
<td>/form.php?id=1</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>fireEventAndWait</td>
<td>id=form</td>
<td>submit</td>
</tr>
</tbody>
</table>

ng-repeat with tables not working

I am a fairly new web developer, just needed quick help with some view code.
I was looping through an object in my controller called "products". I was displaying all the data of each item fine before I wanted to organize it in a table.
Could anyone see the problem with my code? I'm a very weak front end designer, back end is my niche, so it could be a very simple error.
<tr ng-repeat="product in Ctrl.products">
<td><img ng-src= "{{product.image}}"></td>
<td>
<tr>
<td>Name:</td><td>{{product.name}}</td>
</tr>
<tr>
<td>Price:</td><td>{{product.price}}</td>
</tr>
<tr>
{{product.description}}
</tr>
</td>
</tr>
You can't insert a TR inside a TD. You need to insert a full table inside the TD to achieve what you want.
<table>
<tr>
<td>
<table><tr><td>...</td></tr></table>
</td>
</tr>
</table>
You can use rowspan properties:
<table>
<tbody ng-repeat="product in Ctrl.products">
<tr>
<td rowspan="2"><img ng-src= "{{product.image}}"></td>
<td>Name:</td><td>{{product.name}}</td>
<td rowspan="2">{{product.description}}</td>
</tr>
<tr>
<td>Price:</td><td>{{product.price}}</td>
</tr>
</tbody>
</table>

How to make a table that has 3, 2 and 1 columns that fill the whole table?

Disclaimer: I don't usually use tables for layouts but they seem to be the best options for html emails. Believe me, playing with divs
in emails sucks even worse. I'm looking for the best workaround, I
don't have much restraints as to how to design...
I'm almost there but I'm having a problem with the following code:
<table border=1 width="600px">
<tbody>
<tr height="140px">
<td width="210px"></td>
<td width="180px"></td>
<td width="210px"></td>
</tr>
<tr height="200px">
<td colspan="3"></td>
</tr>
<tr height="100px">
<td colspan="3"></td>
</tr>
<tr height="300px">
<td width="300px"></td>
<td></td>
</tr>
</tbody>
</table>
jsfiddle
My specific problem is with the last to cells, that I would like them to divide the space of the table by 50% each.
As you can see I modified the width of the last <td> to 300px (half of the table), but that also modifies the width of the first cell, which is an undesired result, I want the first three td to keep that 210px, 180px, 210px proportion.
Just in case to make it even more clear here is a sketch:
If you must use a table - and you really shoudldn't unless you are displaing tabular data - then the solution here, to my mind, is to make the top row one cell and to nest another table within it, of as many cells width as is needed. So:
<table>
<tr><td colspan="2">
<table><tr>
<td width="210"></td>
<td width="180"></td>
<td width="210"></td>
</tr></table>
</td></tr>
<tr><td colspan="2"></td></tr>
<tr><td colspan="2"></td></tr>
<tr><td width="50%"></td><td width="50%"></td></tr>
</table>
You can't do this with one table. The columns will always line-up. If this is for a layout for some other content, than you really need to look at div-based layouts.
If you have to use tables:
<table border=1 width="600px">
<tbody>
<tr height="140px">
<td width="210px"></td>
<td width="180px"></td>
<td width="210px"></td>
</tr>
<tr height="200px">
<td colspan="3"></td>
</tr>
<tr height="100px">
<td colspan="3"></td>
</tr>
<tr height="300px">
<td colspan="3">
<table>
<tr>
<td width="300"></td>
<td width="300"></td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
Create a table where each column represents each possible division and then use colspans liberally. So you have possible breaks at 210, 300, 490, & 600 for a total of 4 columns.
Then you'd want the first row to span 1, 2, 1, all of the full length to span 4, and then the half and half to span 2 and 2.
DIVs will be better solution here. Are you sure you need a table here? Maybe, divs?