+ 3
<table> or <div>? Why? Why not?
As a beginner, I find it hard to decide when to use <div> or <table>. Which one is more practical? Which one is easier to format?
4 Answers
+ 7
<< The HTML <table> element represents tabular data â that is, information expressed via a two-dimensional data table. >>
source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table
<table> is a semantical element, meaning that it should not be used for layout purpose, which must be handled with appropriate semantical elements related to the content, or non semantical (generic) as <div>...
<div> is used as a generic block type container, for anything which doesnt have well suited existing semantical element ^^
[edit]
About semantical elements:
https://www.w3schools.com/html/html5_semantic_elements.asp
+ 4
Tables are used when you need something like headers, rows, and columns to sort or display your data. DIV is containers that are used for most things, including containing your table. I would say most of the time you'll use a DIV, but if you think you'll need rows, columns, and headers for the columns, then use a table to display the information.
As for formatting, use CSS or similar to style/format the elements. Don't use tables simply because you're wanting to use them to format certain data that's being displayed. That's something we use to do back in the 90s, and it's a horrid means of designing websites. It's the reason why we created CSS.
+ 4
<div> and <table> are not the same at all. <table> creates a board with rows and cols, while <div> is a container to organise CSS (and such) way easier. Just think of <div> as <span> but instead of inline, it's block-type.
+ 3
<div> and <table> are completely different by the function. <div> is used as a container of other elements, in order to manage and modify them easier. On the other hand, <table> is used to create tables (usual tables) using the other tags like <tr> <td> etc, that you are going to learn on HTML fundamentals later...