|
Hey guys, i am learning html and designing basic websites and stuff. What i found out via using firebug is most websites use tables for design instead of divs. I always liked to work with divs.
Why do people prefer tables over divs? I always find divs to be more easy. Most documents i found in the internet says divs are more accurate for design. So what i wanted to ask is if you design with tables what are the logical reasons behind it instead of "i am just used to work with it" ?
Poll: Which one is better overall?Divs + CSS (38) 90% Tables (4) 10% 42 total votes Your vote: Which one is better overall? (Vote): Tables (Vote): Divs + CSS
Here is a nice article about this: http://coding.smashingmagazine.com/2009/04/08/from-table-hell-to-div-hell/
|
My guess is that they're easier to use for new designers.
|
|
On April 30 2012 22:00 IAMFAPMAN wrote: divs > tables imo Yeah but i ask why do you think that way.
|
i think the code is alot easier to read.. never used alot of tables tho
.. and im doing this in my freetime so i learnt everything from the internet or books.
|
Tables are a 90's/early 2000 phenomenon. Last several years it has been known and enforced to write semantic mark-up. Tables are to be used for tabular data, not for layout purposes. I do however think that they may serve a purpose in specific cases (like forms etc.) but generally, seeing tables used for layout is indicating that the developer may not have known what they're doing.
So, use <div>, <section>, <article>, <header>, <footer> etc. (all valid in HTML5, which is widely adopted in any modern web browser) to avoid divitis.
|
On April 30 2012 22:01 Aelfric wrote:Yeah but i ask why do you think that way.
you dont really need to use tables for overall formatting of webpages anymore. divs + stylesheets offers you a bit more freedom in placement of your content, and its overall much cleaner in the code. save tables for truly tabulated data.
|
From my experience positioning elements with divs tends to be more browser-dependent than using tables. Different browsers or resolutions can cause divs to look different than you want them to, so most websites use tables for the basic layout, and divs for anything that goes on top of that. Both have their advantages, but I usually prefer tables for anything i need to place at an exact position, for example a table column is much easier to center on a page by adding blind columns left and right, than a div; and I use divs, when I want to place something dynamically like hover-boxes, dropdown menus or anything I don't know right away where to put it.
|
Divs are just easier and faster way of working in the development world. They're also a lot cleaner since you use the CSS to style everything.
|
Tables were used before CSS really developed/took off. If you're still using them for anything but tabular data your code is likely invalid. Use the w3c validation services to be sure you're coding up to standards.
http://validator.w3.org/
|
This is a silly question, and an apples to oranges comparison to be honest. A lot of you are showing your lack of experience through your answers. Also, it makes me laugh that you say you are just learning but that "You always liked divs" What, so you've been doing this for a month and you've already got an established preference?
Tables are not a "90's phenomenon" I would challenge you to find a major modernized website that doesn't contain at least one table, Google, TeamLiquid, and Amazon.com all use at least one table somewhere on their pages. To be a competent developer you need to understand both and learn to apply them seamlessly.
I think you've got the right idea dissecting pages with Firebug but I feel like you're searching for some absolute technique that doesn't exist. Just keep practising and eventually you're going to get a feel for how things should be put together.
TL;DR, There is no hard and fast rule that says when you should use a table or a Div, you're just going to have to gain some experience to learn when to use which.
|
|
|
On May 01 2012 00:27 Fateless wrote: This is a silly question, and an apples to oranges comparison to be honest. A lot of you are showing your lack of experience through your answers. Also, it makes me laugh that you say you are just learning but that "You always liked divs" What, so you've been doing this for a month and you've already got an established preference?
Yes, so far i liked divs more.
|
As a good design practice, tables should not be used to define structural elements that are not tabular in nature, simple as that. There are a whole host of really good reasons why, the main two being that A. using tables creates a larger html footprint and therefore cause larger document sizes and slower load times (and becomes very expensive if your site gets a lot of traffic, like Google), and B. thanks to html + CSS we have a way to be more flexible with how we structure our layout.
I don't think anyone who's a designer is saying that tables shouldn't be used, we're saying tables should be used for what they were intended to do, present tabular data.
|
Is it wrong to put your tables inside of divs? ^new to CSS/HTML, genuine question.
|
On May 01 2012 00:41 Aelfric wrote:Show nested quote +On May 01 2012 00:27 Fateless wrote: This is a silly question, and an apples to oranges comparison to be honest. A lot of you are showing your lack of experience through your answers. Also, it makes me laugh that you say you are just learning but that "You always liked divs" What, so you've been doing this for a month and you've already got an established preference?
Yes, so far i liked divs more.
Well the problem is just that you have a fundamental misunderstanding of how to use the tools you're talking about. I would try to stop thinking about CSS positioning and tables as having the same purpose; they do not.
When you get into dynamically outputting content you're going to find a lot of situations where tables save you time and produce more consistent results with more compact code that is easier to read. You may then want to apply CSS classes directly to those tables. Even the most pure CSS layout is probably using a <ul> or two. CSS and HTML work together, and tables are just one example of a tag you can apply CSS classes too. It does suck to overuse tables though. You want to make sure you aren't doing things like nesting tables to create a monster layout that would be much simpler with three lists and Float - Clear.
Don't develop a bias towards one tag or method, that kind of thinking is only going to hold you back. As you get more experienced and learn how and when to use code, you will be thankful for every tool you can get your hands on.
Edit: Grammar
|
On May 01 2012 02:11 Chargelot wrote: Is it wrong to put your tables inside of divs? ^new to CSS/HTML, genuine question.
Yes, and no.
Again, there's no hard and fast rule. In many situations you would want to be using classes and apply the class directly to the table.
It depends on the situation though, you might wrap your whole layout in a single div tag with a class applied to constrain the page or set margins.
|
From my own experience I can say that minimal use of tables is the best use of tables. They make everything harder and CSS was basically invented to get rid of table dependant design, among other factors of course. There are situations when tables are the best option, but they shouldn't be overused.
|
Use tables for tables.
Use blocks/divs for layout.
They're not opposed. Tables are also useful for very detailed and structured groupings of elements, such as the icons atop this reply field.
Oh and I practically never use them because I hate typing too much and I do very little front-end work, so nobody expects my stuff to look pretty.
|
|
|
|