Search code examples
htmltabular

Using table or div


What is the best practice when building our web page div or table?

Someone says the div is recommended, but I found it is not easy to control the size and alignment with div.

What is your opinion?


Solution

  • It depends entirely on what you're wanting to display:

    • <DIV> and <SPAN> is for page layout
    • <Table> is for displaying tabular data (such as data points etc)

    The days of using <table> for whole page layouts is gone - and you should be discouraged for using them for this reason.

    HTML tags are meant to be semantic. This means describing the data it contains - not how to display it (this is for stylesheets to handle)