+ 3
What are the advantages using <div> rather using <table> ?
I have created a html page using only <table> and its own components. But my friend said that it is not bad and try to use <div> instead of using <table>
5 ответов
+ 6
There is no real technical advantage to use <div> rather <table>, but it's recommended to follow the semantical meaning of html elements, since you can do same with css. In past, as @Ulisses Cruz said, <table> was the only way to do vertical alignment inside layouts, so <table> was abusely used for that non first purpose....
The good practice rule is:
- <table> when displaying "real" table formatted data
- best suited semantical tag ( <div> is the most generic -- no particular semantical meaning ) styled with css display property using table family values when displaying table for layouts ( or other purposes non fiting in first case )
Benefit is mainly a best ranked page by search engines, after a better readability of code ^^
+ 12
A long long time ago, people had to use table so they could position thing in an HTML page. They didn't had CSS then.
But now there is no need for doing that. Things are more easy with CSS.
+ 4
What do you mean? they're used for different purposes. A div is a container of other elements defining a section in the document, a table is a list of names/images(or whatever you want) organized by rows and columns
+ 3
you can use divs + CSS to do responsive tables. All you can do with table, you can do with divs, With the advantage that the divs can be better adjusted to small screens
0
Tables should only be used for creating tables and HTML emails. Divs should be used to create the layout of a webpage.