I recently had a website to build where the desired layout was three columns - left sidebar, right sidebar, and center content. The sidebars needed to be fixed width and the center content area needed to be liquid and resize itself to use the remaining available space. Pretty standard stuff, right?
Now, CSS has a lot of good points, and I try to be a good girl and drink the Kool-Aid when it makes sense, so I sat down and started making divs. And failed. And failed And failed. CSS just would not produce the result I wanted. So, I said to myself, "Self, there are people out there better than you are with CSS. Surely one of them have solved this!" To Google I went! Where I discovered that the CSS crowd considers this layout to be a "holy grail".
I read dozens of complicated methods for achieving this. I gave some of them a try, but most simply didn't work, or only worked for certain content. That's not such a big deal. All tools have their strengths and weaknesses. What did make me facepalm is the lengths these people are willing to go in order to avoid using the tool that is sitting right in front of them and achieves this effortlessly.
I've got your holy grail right here. It's called a table.
<table style="width:100%">
<tr>
<td style="width:200px">Left Sidebar</td>
<td>Center Content</td>
<td style="width:200px">Right Sidebar</td>
</tr>
</table>
There. Grail found.
Showing posts with label css. Show all posts
Showing posts with label css. Show all posts
Wednesday, November 7, 2012
Tuesday, June 26, 2012
CSS and the War on Tables
Ok, I'm just gonna come right out and say it: I still use tables.
Not for everything, mind you. There are certainly places where divs work better, and I use them. But I've about had it with the hysterical shrieking about how you must use divs for everything, even if they don't work as well, or the webpage police will haul you off to webpage prison where you will do hard webpage time. Seriously, folks, enough. You can have more than one tool in the toolbox.
CSS has a variety of great and useful tools of which I take advantage on a daily basis. That said, I'm tired of pretending that either of the S's stands for "structure." I'm also tired of pretending that sacrificing two chickens and an Amiga to the God of Floats and Margins while praying that nothing moves by so much as a pixel is a reasonable substitute for the tremendously useful balance between rigidity and elasticity that tables provide.
Separating content from presentation is a great idea. I'm all for it. Structure is neither. It's not that I can't do it with divs. I can. I have. I'm not doing it any more. To do what I need structure-wise with divs, I find that I (and others also from the examples they post) end up building the exact same structure with divs that I used to build with table elements. Which would be fine except that it takes at least three times longer and the result is a fragile animal that lets sections be pushed out of position, breaks if the size of the content changes too much, and requires jumping through all sorts of hoops to have two things next to each other stay the same height.
I tried drinking the Kool-Aid. I really did. But I sincerely believe that this is one of those cases where the Emperor needs to tell his tailors to settle the f*** down.
Not for everything, mind you. There are certainly places where divs work better, and I use them. But I've about had it with the hysterical shrieking about how you must use divs for everything, even if they don't work as well, or the webpage police will haul you off to webpage prison where you will do hard webpage time. Seriously, folks, enough. You can have more than one tool in the toolbox.
CSS has a variety of great and useful tools of which I take advantage on a daily basis. That said, I'm tired of pretending that either of the S's stands for "structure." I'm also tired of pretending that sacrificing two chickens and an Amiga to the God of Floats and Margins while praying that nothing moves by so much as a pixel is a reasonable substitute for the tremendously useful balance between rigidity and elasticity that tables provide.
Separating content from presentation is a great idea. I'm all for it. Structure is neither. It's not that I can't do it with divs. I can. I have. I'm not doing it any more. To do what I need structure-wise with divs, I find that I (and others also from the examples they post) end up building the exact same structure with divs that I used to build with table elements. Which would be fine except that it takes at least three times longer and the result is a fragile animal that lets sections be pushed out of position, breaks if the size of the content changes too much, and requires jumping through all sorts of hoops to have two things next to each other stay the same height.
I tried drinking the Kool-Aid. I really did. But I sincerely believe that this is one of those cases where the Emperor needs to tell his tailors to settle the f*** down.
Subscribe to:
Posts (Atom)

