Hi, i am a backend programmer and was asked to create a website for a friend .. i have been following this forum for a while .. can somebody explain to me the benefit of using DIVs and not tables? is it the CODE vs content issue? cheers
Only in part. First, tables were never created to be used for layout. Second, tables are a fixed grid system forcing you to put your content into a pre-determined layout. Third, any other element can be positioned and styled far more than a table and, related, having to change the position or style of content in a table is not always easy. The guy who originally thought of using tables for layout regretted it and published an article saying so back in 1998!! This is not a question anyone should be asking anymore. DIV has been an HTML element since at least that long yet people are still treating it as if it were new.
TABLE is meant for tabular data. so, we can say not only IE there are some people 13 years behind standards.
Yey, get to use one of my all time fav links again. http://www.hotdesign.com/seybold/everything.html Although seriously kinda bored of this topic now.
Tables make your page very large. So increasing load time and cost of your website. Second thing is tables are not comfortable for SEO purpose. Because it inserts lots of unnecessary elements in content of page like td, tr, th etc.. Using DIV for your website makes your webpage more search engine friendly..
I just had this conversation with someone I was training recently. As I shared with them there are a bunch of sites built on tables. Even though there are few advantages to tables, I agree with others here that building a layout based on DIV's is far superior. I was even able to do a side by side comparison to show them the advantages of using div's. A layout based on a table is very rigid and difficult to update site wide. Editing a CSS file is much easier than updating 10, 20, 100 pages that used tables. It requires more html code to build a layout with tables. With all that said, here is why I think div's are better. It gives the designer greater flexibility in creating the layout. One site I know that shows this is css Zen Garden.
You do NOT base layouts on the div element. DIVs are just one of the elements you use to structure a page. Some pages I've created have NO divs at all.
So how would you advise setting up a 3 column layout with header and footer with no divs? Yeah if you simpley have a very basic bage with text, images and lists you can do it without divs but generally 99.9% of websites ever made need divs or tables for layout and tables are the worst option you could possibly even think of for a website. Tables should only be used for displaying tabular data. I dont get why people are still even asking this question to be honest, the same question has been asked and answered with the same answer for years and years.
Depends. Notice I didn't say not to use divs. I said you don't base a layout on one HTML element. A div is a helpful HTML element just like all the others.
It is a myth that search engines will rank you down. IF you are more comfortable with tables use tables, if you are happier with divs, use divs. Like I keep telling people, if you provide the content, they will come. Google will see your page in the same way wether it is divs or tables.