HTML table tricks
Need to show tables?
HTML tables, some people love them, some people hate them. But there are surely quite some tricks we can do about it.
selectable columns
Modified from DBMS comparison, when we have checkboxes such as input#on-category
with the id, we can toggle the display of the table columns with this
body:not(:has(input#on-category:checked)) table.toggle tr :nth-child(1),
body:not(:has(input#on-name:checked)) table.toggle tr :nth-child(2),
body:not(:has(input#on-type:checked)) table.toggle tr :nth-child(3),
body:not(:has(input#on-use:checked)) table.toggle tr :nth-child(4) {
display: none;
}
Note: Please be aware of that, if there are cells with colspan
, toggling the column containing first cell will remove the entire row. For example, toggling Column Name will entirely remove the Polysporin row below.
Category | Name | Type | Use |
---|---|---|---|
Acne medication | Benzoyl peroxide 2.5% | gel/cream/lotion | |
Benzoyl peroxide 5% | gel/cream/lotion | ||
Benzoyl peroxide 5% | wash | ||
Benzoyl peroxide 10% | wash | ||
Salicylic acid foam | SalAc Foam | ||
Antibiotics & Antiseptics | Double antibiotic ointment (Polysporin) | ||
Hibiclens cleanser | |||
Antifungal medication | Clotrimazole | cream/solution | twice daily |
Miconazole | cream/solution | ||
Lamisil | cream/solution | ||
Itch-relief medication | Sarna | lotion | |
Sarnol-HC (with 1% hydrocortisone) | lotion | ||
Aveeno Anti-Itch Concentrated Lotion | |||
Benadryl | cream | ||
Keloid treatment (silicon gel) | Morelle SOS sheets | ||
Band-Aid Scar Therapy | |||
Rash medication/treatment | Hydrocortisone 1% | cream/ointment | |
Aveeno Bath treatment | |||
Bluboro/Domeboro soaks | |||
Skin protectant | Zinc oxide cream/paste (Desitin) | ||
BodyGlide | |||
Wart treatment | Wart removal liquids (17% salicylic acid) | solution | |
Mediplast patches (40% salicylic acid) | |||
Miscellaneous | Ammonium lactate 12% lotion | lotion | |
Ela-Max 4% topical anesthetic | |||
Minoxidil 2%, 5% | solution |
Sticky table heads
To make the table head always stay even under scrolling, please use CSS tricks on position
. It’s very useful for the long tables.
table {
width: 100%;
position: relative;
border-collapse: collapse;
}
th {
ackground: white;
position: sticky;
top: 0;
}
Example: CIDR notation(Classless Inter-Domain Routing) table.
CIDR prefix length | Dotted Decimal Netmask | Number of Classful Networks | Number of Usable IPs | Note |
---|---|---|---|---|
/1 | 128.0.0.0 | 128 As | 2147483646 | 2^(32-1)-2 |
/2 | 192.0.0.0 | 64 As | 1073741822 | 2^(32-2)-2 |
/3 | 224.0.0.0 | 32 As | 536870910 | 2^(32-3)-2 |
/4 | 240.0.0.0 | 16 As | 268435454 | 2^(32-4)-2 |
/5 | 248.0.0.0 | 8 As | 134217726 | 2^(32-5)-2 |
/6 | 252.0.0.0 | 4 As | 67108862 | 2^(32-6)-2 |
/7 | 254.0.0.0 | 2 As | 33554430 | 2^(32-7)-2 |
/8 | 255.0.0.0 | 1 A or 256 Bs | 16777214 | 2^(32-8)-2 |
/9 | 255.128.0.0 | 128 Bs | 8388606 | 2^(32-9)-2 |
/10 | 255.192.0.0 | 64 Bs | 4194302 | 2^(32-10)-2 |
/11 | 255.224.0.0 | 32 Bs | 2097150 | 2^(32-11)-2 |
/12 | 255.240.0.0 | 16 Bs | 1048574 | 2^(32-12)-2 |
/13 | 255.248.0.0 | 8 Bs | 524286 | 2^(32-13)-2 |
/14 | 255.252.0.0 | 4 Bs | 262142 | 2^(32-14)-2 |
/15 | 255.254.0.0 | 2 Bs | 131070 | 2^(32-15)-2 |
/16 | 255.255.0.0 | 1 B or 256 Cs | 65534 | 2^(32-16)-2 |
/17 | 255.255.128.0 | 128 Cs | 32766 | 2^(32-17)-2 |
/18 | 255.255.192.0 | 64 Cs | 16382 | 2^(32-18)-2 |
/19 | 255.255.224.0 | 32 Cs | 8190 | 2^(32-19)-2 |
/20 | 255.255.240.0 | 16 Cs | 4094 | 2^(32-20)-2 |
/21 | 255.255.248.0 | 8 Cs | 2046 | 2^(32-21)-2 |
/22 | 255.255.252.0 | 4 Cs | 1022 | 2^(32-22)-2 |
/23 | 255.255.254.0 | 2 Cs | 510 | 2^(32-23)-2 |
/24 | 255.255.255.0 | 1 C | 254 | 2^(32-24)-2 |
/25 | 255.255.255.128 | 1/2 C | 126 | 2^(32-25)-2 |
/26 | 255.255.255.192 | 1/4 C | 62 | 2^(32-26)-2 |
/27 | 255.255.255.224 | 1/8 C | 30 | 2^(32-27)-2 |
/28 | 255.255.255.240 | 1/16 C | 14 | 2^(32-28)-2 |
/29 | 255.255.255.248 | 1/32 C | 6 | 2^(32-29)-2 |
/30 | 255.255.255.252 | 1/64 C | 2 | 2^(32-30)-2 |
/31 | 255.255.255.254 | 1/128 C | 0 | 2^(32-31)-2 |
/32 | 255.255.255.255 | 1/256 C | 1 | reserved |
ps. There are some range of IPv4 address reserved for special uses.
blog comments powered by Disqus