CSS or tables for layout?

  Nyck 21:06 07 Dec 04
Locked

I am interested in your views on using CSS and/or tables for layout. When I view the source of a web page the code always seems to be based on tables. Maybe this is bacause most web pages are designed using HTML editors. This is fine but in my limited knowledge of HTML I thought the use of CSS to format the layout was the way forward. Maybe it does'nt really matter because if I don't use table> elements I still need as many or more div> elements.

Are there things you can do with tables which you can't with CSS?

Cheers in advance.

Nick

  Forum Editor 23:57 07 Dec 04

Tables for your layout (which may vary from page to page) and Cascading Style Sheets to specify font point sizes, font attributes (italics, underline, etc), page margins, colors, spacing and positioning.

Experiment with both these methods and see for yourself which suits your particular requirements.

  Taran 16:29 08 Dec 04

If you have, as you say, a limited knowledge of HTML, I'd suggest you may be better off learning more of it than trying to learn a completely new coding standard like CSS.

Ideally of course, you should learn both.

All I'm meaning is if you are struggling with a layout using HTML or a WYSIWYG editor, adding CSS into the mix is more likely to complicate things further than offer an easy way out.

In many cases I use CSS only or, as Forum Editor suggests, HTML tables can be combined with CSS which is used to control how things look while the table controls where things are on the page.

  Nyck 19:25 08 Dec 04

Thanks for the replys.

The reason for my post was not because I'm particularly struggling but that I'm not really sure of the benifits of using tables.

I like using CSS and can't see what tables can do which CSS can't.

  Taran 21:47 08 Dec 04

Complex HTML tables cannot be emulated in CSS without a lot of code hacking. This is required to get a consistent display in alternative browsers.

Having said that, a complex HTML table can also fail in alternative browsers, as I'm sure you probably know.

In fact, many people choose to ignore the old saying of "just because you can do someting doesn't necessarily mean that you should" and they charge on in using multiple nested tables. Try getting THEM to behave in a predictable manner...

I could go on and one about the comparative pros and cons of tables v CSS (let's face it, I can go on about anything) but that is a huge debate and there are a lot of good reasons why both can be more than acceptable.

CSS can remove a lot of HTML code bloat for formatting and has the obvious advantages associated with one file edit = global sitewide change. For general table structures I see little real benefit to using CSS to control the rows and columns.

It's a horses for courses argument really, since certain table layouts can be delivered effectively using either method and both will produce accesible results, up to a point.

Challenging the limits of one often forces your hand with the other.

I like and use both but tend to steer towards CSS for most sites. Then again, I don't often use complex table structures to control page layouts. Most of my sites lean to a simpler, cleaner approach.

  Nyck 23:46 08 Dec 04

I was half expecting you guys to answer as you always seem ready to offer us novices good advice.

It seems I should maybe try using tables a bit more for the basic page layout while sticking with CSS for the rest.

Thanks again.

Nick

  Forum Editor 00:40 09 Dec 04

a great degree of versatility when it comes to layout, although it's wise to resist the temptation to indulge in a plethora of nested tables - they'll tend to slow the page loading time because the browser has to do a lot of calculations in order to work out how to place all the items that are in your table.

Tables also make it easy to have white space on a page - something that can aid readability.

  Talented Monkey 10:59 10 Dec 04

Well Taran has yet again beaten me to this so i wont bother repeating things.

All ill add is that <table> was not originally designed for layout, but it is very stable and was quickly adopted for work around solution and has become "standard" although its not compliant.

CSS is improving, and has been said, both have pros and cons, its not particularly difficult to lay out most average pages in CSS using <div> but there can be the odd unexpected bug, one thing I come across, is layout is fine in reduced window, but when expanded to a full size window, everthing collapsed and ended up being listed vertically down the page.

I try not to use tables these days bet there comes a time when its a lot less hassle to stick one in!

Have you looked at CSS Zen Garden? click here this shows you what can be done without using tables for a layout.

  Nyck 21:03 10 Dec 04

I had a look at the page you mention. It seems to me the guy is trying to keep the image of the hallway in the centre of the window (presumably intentionally) and so you loose the left hand side of the page. Why you would want to do that I don't know.

This thread is now locked and can not be replied to.

Huawei P10 review

1995-2015: How technology has changed the world in 20 years

An overview: What leading creative agencies are doing to improve diversity

New iPad, iPhone SE & Red iPhone 7 on sale now