Should i use tables in html5




















So, if you want to write valid HTML 4. You should only use tables for tabular data, and tabular data generally looks like something you might display in a spreadsheet or possibly a database. Actively scan device characteristics for identification. Use precise geolocation data. Select personalised content.

Create a personalised content profile. Measure ad performance. Select basic ads. Create a personalised ads profile. Select personalised ads. Apply market research to generate audience insights. Measure content performance. Develop and improve products. List of Partners vendors. Share Flipboard Email. Jennifer Kyrnin. Updated April 11, Table of Contents Expand. Tables Are Not Accessible. Tables Are Tricky.

All those elements are intended to be used with tables, and believe me, they can make your table much more self-descriptive. This should keep anyone safe. Use this as a rule of thumb.

Tables should only be used when displaying tabular data. Otherwise, they are usually a poor choice for display. This tells the browser to analyze the table and fix the cells to contain the elements inside them, which takes some time. Bottom line: the table will render after all the content inside it is rendered, as opposed when using for example DIV elements. I use tables for web design structure in liquid mixed with fixed and I know many says tables are for noobs others says they are for old school guys those always says DIVS are the best but the truth is that tables are better for some thing and DIVS for other thing.

Obviously inside tables is ugly to put more and more tables, that's where DIVS comes handy. Tables can do things divs cannot and divs can do things tables cannot. Do you see the potential now? Take a look to it on PC and cellphone. Ah yeah and I don't even need bootstrap. Now to do the same with divs you have to write a lot of CSS code to display align float and crap.

Who wrote less code? What does customers need? A guy ending a page in 1 year or in 1 month? Your answer is: they both together work better and is faster and it will look good on any design even on TVs and small cellphones.

Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Ask Question.

Asked 10 years, 11 months ago. Active 1 year, 1 month ago. Viewed 16k times. Improve this question. Incognito Incognito 1, 1 1 gold badge 10 10 silver badges 21 21 bronze badges.

Please join us on this journey from hell to heaven. Tables generally increase the complexity of documents and make them more difficult to maintain. On the list of 10 most popular tags, table , td and tr are all there. Semantically speaking, the table tag is meant for listing tabular data. It is not optimized to build structure.

Using tables to build structure is quite intuitive. We see tabular data every day, and the concept is well known. Columns are not squeezed under other columns as they are in a div-based structure. This adds to the feeling that using tables is safe. Table contains different tags: the table tag being the wrapper, tr for each row and td for each cell. The thead and tbody tags are not used for structural purposes because they add semantic meaning to the content. For readability, each tag is normally given its own line of code, with indention.

With all of these tags for the table, several extra lines of code are added to content. The colspan and rowspan attributes make the code even more complex, and any developer maintaining that page in future has to go through a lot of code to understand its structure. As we see from the example, the table-based layout contains more code than the div-based version. Imagine now if this difference in size stays consistent as the code base grows by a ratio as much as In a div-based structure, it is also possible to skip the menu div and use an unordered list ul as a container instead.

Nested tables are code smell that a website is stuck in table hell. The number of lines of code is endless, and the complexity is overwhelming. Nested tables are a poor substitution for semantically meaningful, block-level elements.

Another drawback to tables is that they make it harder to separate content from design. This adds code to the HTML that should instead go in the style sheet. Excess code slows down development and raises maintenance costs. Developers may not even understand their own code after a while. More lines of code mean larger file sizes, which mean longer download times. Developers should keep in mind new media, such as mobile devices, which usually have low bandwidth.

Websites will have to support media other than traditional monitors in future, and bad code limits the possibilities. A large code base has more bugs than a small one. Developers tend to produce a certain number of bugs per line of code.

Because tables increase the code base, such structures likely contain more bugs than layouts with less code lines. In an ideal world, the same markup would be used for printers, mobile devices, screens and other media. Using tables for structure provides less flexibility in moving columns around and hiding entire columns. Your user may want to put the side column at the bottom or view a printer-friendly version. With tables, this would require a separate page for each media , which means extra costs during development and higher maintenance costs compared to a div-based website that separates content and design.

Websites in div hell have more div tags than are necessary. The div tag is a block-level element that defines a section within a document. Divs are thus suitable for building the structure of Web pages. The div tag is also used to describe content that cannot be properly described by other more semantic tags.

When developers do not understand the semantic meaning of other block-level elements, they often add more div tags than are needed. Div-based structures have a much steeper learning curve than table-based structures. The developer must know CSS and understand the difference between block-level elements and inline elements, when to use floats and when to use absolute positioning and how to solve browser bugs. Everyone knows what a table looks like, but divs are not as obvious. Using a div for structure can make a page more fragile when content is pushing the div to its limit.

It can also force columns to fall under each other. But this is usually only true for older browsers particularly IE6 ; newer browsers make content flow to the next column. Dealing with browser bugs can be a little tricky at first, but with experience developers can identify and fix them. Browser support for W3C standards is getting better and better. With the growing popularity of Firefox and Safari and the introduction of Google Chrome , we are seeing a big fight over market share, which inevitably makes for better browsers.

The biggest problem with div tags is that they are used too often. Divs should only be used to build structure and as placeholders for design elements when no other block-level elements can describe the content. The div tag is for logical groupings of elements. True, using descriptive class and structure names makes the code more understandable, but using them for nested div tags is not always easy. It means divs are being used when semantic block-level tags would better describe the content; for instance, headings should be wrapped in h1 to h5 tags.

Writing semantic code usually reduces the code base; and less divs with floats helps keep browser bugs away. Of course, ids and classes can carry semantic values that no other tags have.



0コメント

  • 1000 / 1000