Code has been added to clipboard!

The table HTML Tag

Reading time 2 min
Published Jun 29, 2017
Updated Oct 11, 2019

table HTML: Main Tips

Defining a Table in HTML

By using table HTML tags, you can include a table with rows and columns in the web page:

Example
<table>
  <tr>
    <th>Place</th>
    <th>Animal</th>
  </tr>
  <tr>
    <td>Space</td>
    <td>Dog</td>
  </tr>
</table>

To style your table, you can use CSS properties. If you don't, these values will be set by default:

Example
table { 
    display: table;
    border-color: gray;
    border-collapse: separate;
    border-spacing: 2px;
}

Deprecated HTML Table Attributes

The previously used HTML table attributes have been deprecated in HTML5. Get familiar with them, but don't use them in your codes:

Attribute Purpose Alternative
align Defined the table alignment in relation to the surrounding text CSS float
width Defined the table width CSS width
border Set the table border CSS border
cellpadding Defined the cell content and the cell wall CSS padding
cellspacing Defined the space between cells
frame Defined what should be visible outside the borders
rules Defined what should be visible inside the borders CSS border
summary Defined a summary for a table
bgcolor Specified the background color for a table CSS background-color

Browser support

Chrome
1+
Edge
All
Firefox
1+
IE
All
Opera
All
Safari
All

Mobile browser support

Chrome
18+
Firefox
4+
Opera
All
Safari
All
Basics
Introduction
Syntax
Editors
Basic Examples
Head Section
<!DOCTYPE>
Tags and Elements
Semantic Elements
Tags Reference
Attributes
Comments
Block and Inline Elements
Forms
Form Elements
Input
Responsive Web Design
Inline Scripts
Uniform Resource Locator
Redirect
XHTML
Geolocation
Drag and Drop
Local Storage
Web Workers
Server-Sent Events
Character Encoding
Text Formatting
Quotation and Citation Elements
Headings
Paragraphs
Links
Tables
Lists
Symbols
Space
Tab
Styles
Computer Code
Layout
Classes
Colors
Images
iframes
Audio Player
Video Player
YouTube Videos
Multimedia
Canvas
SVG
<!-- -->
<a>
<abbr>
<acronym> DEPRECATED
<address>
<applet> DEPRECATED
<article>
<aside>
<audio>
<b>
<base>
<basefont> DEPRECATED
<bdi>
<bdo>
<big> DEPRECATED
<blink> DEPRECATED
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center> DEPRECATED
<cite>
<code>
<col>
<colgroup>
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<dir> DEPRECATED
<div>
<dl>
<dt>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<font> DEPRECATED
<footer>
<form>
<frame> DEPRECATED
<frameset> DEPRECATED
<h1> – <h6>
<head>
<header>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<keygen> DEPRECATED
<label>
<legend>
<li>
<link>
<main>
<map>
<mark>
<menu>
<menuitem> DEPRECATED
<meta>
<meter>
<nav>
<noframes> DEPRECATED
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike> DEPRECATED
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<tt> DEPRECATED
<u>
<ul>
<var>
<video>
<wbr>