/    Sign up×
Community /Pin to ProfileBookmark

when to use a div or a table

Hi there,

Recently I have done a lot with the div tag – I like it… The question is going forward I plan to remove the use of tables and start using divs to create layouts however sometimes I wonder – “is it just better to use a table here?” For example an input form, you want everything to line up nicely and whatever – you wouldn’t want have a create a bunch of div’s indside of div’s that would seem like a lot of work.

Is there a better way to do it? Or in that situation should I just use a table?

Thanks for your advice.

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@ray326Feb 11.2008 — You use tables when you have tabular data to display. Arguably a form is single row tabular data but it's much better handled with appropriate form tags like "label" along with divs and CSS to pretty things up. I don't see that labels and divs inside of divs, fieldsets, labels, etc. are any more work than cells in rows in tables in cells in rows in tables.
Copy linkTweet thisAlerts:
@felgallFeb 11.2008 — Use tables for tabular data.

Use divs for divisions within your page.

Use whatever other HTML tag is most appropriate for the content you have in your page that isnn't a division or tabular data.

Too many people get rid of the non-semantic table from their page and replace it with equally non-semantic divs which means that their page is no better semantically that it was before.
×

Success!

Help @r0k3t spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...