Post number #819165, ID: cc0c04
|
Am learning CSS atm, merged two of the header cells, but I want to change lengths of just one of the two columns. Is there a way?
Post number #819270, ID: 1feb09
|
Drop.table
Post number #819295, ID: 9cb5d5
|
I don't know but I would expect a div inside a cell would let you expand one.
Post number #819596, ID: cc0c04
|
>>819295 it...works. I feel like there should be a better way to do this, but I'll take it for now. Thanks.
Post number #819597, ID: 2a3c99
|
Just use `width: []` on the cell's styling. A `width: 70%` on the first of the two cells in a row will ensure it takes up 70% of the total width, while the second cell takes the rest.
If you want to change the width of all the cells in that column, use a selector like this:
td:nth-child(1) { width: 70%; }
Post number #819625, ID: cc0c04
|
>>819597 nth-child doesn't work because each row doesn't have the same amount of cells, so it ends up affecting other columns.
Post number #819741, ID: 2a3c99
|
>each row doesn't have the same amount of cells They... don't? What do you mean by "column" then? HTML doesn't actually understand the concept of a "column". It's just rows with cells in it.
You can use a class on the weirdly-sized cells, I guess?
Honestly if your table's kinda funky, I'd suggest using grid or flexbox instead. HTML's table is kind of a relic at this point.
Post number #819750, ID: cc0c04
|
>>819741 they do tho? I set colspan on one of the header cells to two.
Post number #819763, ID: 2a3c99
|
>>819750 ...? Oh you mean about HTML understanding the concept of column. Huh. Yeah, I guess they do. They're just not elements on their own, so you can't style them the same way.
Maybe you can use colgroup? https://developer.mozilla.org/en-US/docs/Web/HTML/Element/colgroup
Then again I'm not really sure what you want. I guess some rows have cells with a set colspan and some don't?
Post number #819765, ID: 2a3c99
|
(Also gotta add that I've been a web developer for over ten years and I've never used colgroup. It's a weird piece of web standard)
Post number #819802, ID: cc0c04
|
>>819763 ye to your second question. I forgot colgroup existed lmao. Thanks, now the code looks right, though I guess this shows that html tables really are becoming archaic, aren't they.
Post number #820552, ID: 15f53d
|
Separate question from op: are html tables still used? I keep hearing to stop using them but alternatives I've found are just making manually with divs? Is that accessibility friendly?
Post number #820555, ID: 2a3c99
|
>>820552 Tables can still be used if you're actually showing data and statistics and the likes.
Absolutely do not use it for layouting purpose. Like, don't use it to make an image gallery. Grid and flexbox exists.
Total number of posts: 13,
last modified on:
Wed Jan 1 00:00:00 1641295186
| Am learning CSS atm, merged two of the header cells, but I want to change lengths of just one of the two columns. Is there a way?