I'm new to HTML/CSS, and I'm having a hard time aligning the Opening days, hours, closing days of the Chicken shop against the Open, Hours, and Close from the table. I want the days and time to align directly below each category. Such as Open (Sun/Mon..), Hours (9-3pm), Close (Tues/Fri). Below are my codes, any advise would be greatly appreciated!!! Thank you!!!
<table id="shops">
<tr>
<th>Shops</th>
<th>Location</th>
<th>Store Hours</th>
<th>Products</th>
</tr> <!-- Nested table for store hours and product types-->
<tr>
<td colspan="2"></td>
<td>
<table id="hours_table">
<tr>
<th>OPEN</th>
<th>HOURS</th>
<th>CLOSE</th>
</tr>
</table>
</td>
<td>
<table id="products_table">
<tr>
<th>Animals</th>
<th>Cost</th>
<th>Items</th>
<th>Cost</th>
</tr>
</table>
</td>
</tr>
<tr>
<td id="chicken_shop">Cuckoo House Chicken Shop</td>
<td>West Natura</td>
<td>
<table id="chicken_hours">
<tr>
<td>SUN/MON/WED/THURS/SAT</td>
<td>9AM - 3PM</td>
<td>TUES/FRI</td>
</tr>
</table>
</td>
</table>
Hi here is the solution:
<table id="shops" border='1'>
<tr>
<th>Shops</th>
<th>Location</th>
<th>Store Hours</th>
<th colspan="4">Products</th>
</tr> <!-- Nested table for store hours and product types-->
<tr>
<td id="chicken_shop">Cuckoo House Chicken Shop</td>
<td>West Natura</td>
<td>
<table width="333" id="hours_table" border='1'>
<tr>
<td>OPEN</td>
<td>HOURS</td>
<td>CLOSE</td>
</tr>
<tr>
<td>SUN/MON/WED/THURS/SAT</td>
<td>9AM - 3PM</td>
<td>TUES/FRI</td>
</tr>
</table>
</td>
<th>Animals</th>
<th>Cost</th>
<th>Items</th>
<th>Cost</th>
</tr>
</table>
Instead of using <th> you have to use <td> even if it is part of the table head.
<table>
<thead>
<tr>
<td>Shops</td>
<td>SOmethng</td>
<td>Something#2</td>
</tr>
</thead>
<tbody>
<tr>
<td>Something in the body of the table</td>
<td>something</td>
<tdSomething</td>
</tr>
</tbody>
</table>
I suggest using w3schools.com for additional info.Also you can add borders in case you want some borders around it.
Related
Example
This is a "T-account" as shown in the book Principles of Macroeconomics by Gregory Mankiw:
Code
To render this, I took the approach of using nested tables:
<table class="table">
<thead>
<tr>
<th>ASSETS</th>
<th>LIABILITIES AND OWNERS' EQUITY</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<table>
<tr>
<td>Reserves</td>
<td style="text-align: right;">200</td>
</tr>
<tr>
<td>Loans</td>
<td style="text-align: right;">700</td>
</tr>
<tr>
<td>Securities</td>
<td style="text-align: right;">100</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>Deposits</td>
<td style="text-align: right;">800</td>
</tr>
<tr>
<td>Debt</td>
<td style="text-align: right;">150</td>
</tr>
<tr>
<td>Capital</td>
<td style="text-align: right;">50</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
In my application (with some CSS that comes with Blazor) here's the result:
Question
This seems to work OK, although it seems a bit odd. There's the assumption that the rows in each table will always align, for example.
Is there a better or more idiomatic way to implement the T-account in HTML?
So lets say, in a HTML snippet, I have some non-table tags, then a <table> tag, then some non-table tags, then another <table> tag and so on.
What I wanna do is get the first set of non-table tags into one group, then the table section in another and the next set of non-table tags into another and so on.
I have tried using regex. It is becoming superly complicated. I have tried searching how to do using BeautifulSoup but no use.
And also, if I have to extend it to ordered <ol> and unordered <ul> sections, how can I do it?
For example: I have this (HTML) string:
<h2>Hello There.</h2>\n
<p>
Click ME </p>
<p>Lets have a coffee</p>\n
<table>
<tbody>
<tr>
<th>Drink</th><th>Cost</th></tr>
</tbody>
<tbody>
<tr>
<td>Coffee</td><td>152.61 </td> </tr>
<tr>
<td>Coke</td><td>62.56</td> </tr>
<tr>
<td>Pepsi</td><td>21.71</td> </tr>
</tbody>
</table>
<p>
So? click me too. Here is another list</p>
<table>
<tbody>
<tr>
<th>Food</th><th>cost</th></tr>
</tbody>
<tbody>
<tr>
<td>Bhel</td><td>25.5</td> </tr>
<tr>
<td>Puri</td><td>23.0</td> </tr>
<tr>
<td>Something</td><td>19.4</td> </tr>
<tr>
<td>Pani</td><td>17.12 </td> </tr>
<tr>
<td>Puriya</td><td>10.64 </td> </tr>
<tr>
<td>Done</td><td>9.21</td> </tr>
<tr>
<td>Rice</td><td>9.20 </td> </tr>
</tbody>
</table>
<p>This amazing collection is here.</p>
Required Result:
[<h2>Hello There.</h2>
<p>
Click ME </p>
<p>Lets have a coffee</p>,
<table>
<tbody>
<tr>
<th>Drink</th><th>Cost</th></tr>
</tbody>
<tbody>
<tr>
<td>Coffee</td><td>152.61 </td> </tr>
<tr>
<td>Coke</td><td>62.56</td> </tr>
<tr>
<td>Pepsi</td><td>21.71</td> </tr>
</tbody>
</table>,
<p>
So? click me too. Here is another list</p>,
<table>
<tbody>
<tr>
<th>Food</th><th>cost</th></tr>
</tbody>
<tbody>
<tr>
<td>Bhel</td><td>25.5</td> </tr>
<tr>
<td>Puri</td><td>23.0</td> </tr>
<tr>
<td>Something</td><td>19.4</td> </tr>
<tr>
<td>Pani</td><td>17.12 </td> </tr>
<tr>
<td>Puriya</td><td>10.64 </td> </tr>
<tr>
<td>Done</td><td>9.21</td> </tr>
<tr>
<td>Rice</td><td>9.20 </td> </tr>
</tbody>
</table>,
<p>This amazing collection is here.</p>]
a list containing the parts
I want to create table with main section and subsections like that
I tried
<html>
<body>
<table style="width:100%">
<tr>
<td rowspan="3">section</td>
<td rowspan="3">subsection1</td>
<td rowspan="2">subsection1</td>
<td rowspan="1">subsection1</td>
</tr>
<tr>
<td>text1</td>
</tr>
<tr>
<td>text2</td>
</tr>
<tr>
<td>text3</td>
</tr>
...
</table>
</body>
</html>
but this code dont create dont create subsections. Surrounding subsection1 with also dont create subsections.
The rowspan attribute indicates the number of rows a cell should take up. There are 6 rows total in your table, so if you want a cell to span to the last row of the table, you specify rowspan="6". Note that the rowspan values should sum up to the same number for each column, the default value being 1.
<table style="width:100%">
<tr>
<td rowspan="6">section</td>
<td rowspan="3">subsection1</td>
<td>text1</td>
</tr>
<tr>
<td>text2</td>
</tr>
<tr>
<td>text3</td>
</tr>
<tr>
<td rowspan="2">subsection2</td>
<td>...</td>
</tr>
<tr>
<td>...</td>
</tr>
<tr>
<td rowspan="1">subsection3</td>
<td>...</td>
</tr>
</table>
See this JSFiddle
What is the term of this table arrangement?
and I want to make a like that using bootstrap, but I fail so many times.
(also I already google it)
that is why I am here to look someone know how to do it.
I assume you are specifically referring to the use of colspan to cover multiple columns with one cell and rowspan to cover multiple rows with one cell
<table>
<tr><td rowspan="2">FOO</td><td colspan="4">EXAMPLE</td></tr>
<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>
<tr><td>1. Something here</td><td></td><td></td><td></td><td></td></tr>
<tr><td>2. Something here</td><td></td><td></td><td></td><td></td></tr>
<tr><td>3. Something here</td><td></td><td></td><td></td><td></td></tr>
<tr><td>4. Something here</td><td></td><td></td><td></td><td></td></tr>
</table>
Try like this:
Demo
HTML:
<table class="table table-bordered">
<thead>
<tr>
<th rowspan="2">Heading</th>
<th rowspan="2">Heading</th>
<th colspan="4">Heading</th>
</tr>
<tr>
<th>Heading</th>
<th>Heading</th>
<th>Heading</th>
<th>SHeading</th>
</tr>
</thead>
<tbody>
<tr>
<td>3546 </td>
<td>89789</td>
<td>3546</td>
<td>789789</td>
<td>56456757</td>
<td>56456757</td>
</tr>
<tr>
<td>3546 </td>
<td>89789</td>
<td>3546</td>
<td>789789</td>
<td>56456757</td>
<td>56456757</td>
</tr>
<tr>
<td>3546 </td>
<td>89789</td>
<td>3546</td>
<td>789789</td>
<td>56456757</td>
<td>56456757</td>
</tr>
<tr>
<td>3546 </td>
<td>89789</td>
<td>3546</td>
<td>789789</td>
<td>56456757</td>
<td>56456757</td>
</tr>
</tbody>
I am having problems with formatting a table. For some reason, the colspans and rowspans are not working and the cells are just dropped into the first row and column available. I have made column groups specifying the width of the columns. I have the code here:
<table class = “programs” border=“1”
summary=“Lists the morning programs aired by KPAF from 5:00 a.m. to 12:00p.m.(central time).>
<caption> All Times Central </caption>
<colgroup>
<col class = “timeColumn” />
<col class = “wDayColumns” span =“5”/>
<col class = “wEndColumns” span=“2”/>
</colgroup>
<thead>
<th>Time</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
<th>Saturday</th>
<th>Sunday</th>
</thead>
<tbody>
<tr>
<th>5:00</th>
<td colspan =“5” rowspan=“4”>Dawn Air</td>
<td colspan =“1”>Dawn Air Weekends</td>
<td colspan =“1”>Sunday Magazine</td>
</tr>
<tr>
<th>5:30</th>
</tr>
<tr>
<th>6:00</th>
<td col = “1” rowspan = “2”>Weekend Reflections</td>
</tr>
<tr>
<th>6:30</th>
</tr>
<tr>
<th>7:00</th>
<td colspan=“5”> Local News</td>
<td colspan=“1” rowspan=“2”>Weekend Wrap</td>
<td colspan=“1” rowspan=“2”>Radio U</td>
</tr>
<tr>
<th>7:30</th>
<td colspan=“5”>World News Feed</td>
</tr>
<tr>
<th>8:00</th>
<td colspan=“5” rowspan=“4”>Classical Roots</td>
<td colspan=“1” rowspan=“3”>What can you say?</td>
<td colspan=“1” rowspan=“4”>University on the air</td>
</tr>
<tr>
<th>8:30</th>
</tr>
<tr>
<th>9:00</th>
</tr>
<tr>
<th>9:30</th>
<td colspan=“1” rowspan=“4”>Animal Talk</td>
</tr>
<tr>
<th>10:00</th>
<td colspan=“5” rowspan=“4”>Symphony City</td>
<td colspan=“1” rowspan=“1”>Word Play</td>
</tr>
<tr>
<th>10:30</th>
<td colspan=“1” rowspan=“1”>Brain Stew</td>
</tr>
<tr>
<th>11:00</th>
<td colspan=“1” rowspan=“3”>Opera Live from the East Coast</td>
<td colspan=“1” rowspan=“1”>The Inner Mind</td>
</tr>
<tr>
<th>11:30</th>
<td colspan=“1” rowspan=“1”> Grammar Rules!!</td>
</tr>
<tr>
<th>12:00</th>
<td colspan=“5” rowspan=“1”>Book Club</td>
<td colspan=“1” rowspan=“1”>Weekend Wrap</td>
</tr>
</tbody>
</table>
it's because you are using bad quotes “,”. You have to use normal ones " (ASCII code: 034)