  {"id":3519,"date":"2024-12-11T11:54:05","date_gmt":"2024-12-11T16:54:05","guid":{"rendered":"https:\/\/www.montclair.edu\/university-communications\/?page_id=3519"},"modified":"2024-12-11T12:29:14","modified_gmt":"2024-12-11T17:29:14","slug":"tables","status":"publish","type":"page","link":"https:\/\/www.montclair.edu\/university-communications\/web-development-and-experience\/html-tips-and-accessibility\/tables\/","title":{"rendered":"Tables"},"content":{"rendered":"<p>The <strong>table <\/strong>tag is intended to hold tabulated data. Unlike a list or a paragraph, data in a table is given additional meaning by its placement within the row\/column structure.<\/p>\n<p>Never use a <strong>table<\/strong> to control page design layout. If you want to arrange items in rows and columns, see <a href=\"http:\/\/www.montclair.edu\/web-services\/montclair-edu-website-framework\/wordpress-shortcodes\/rows-and-columns\/\">Rows and Columns<\/a>.<\/p>\n<p>Tables are required to have a <strong>thead<\/strong> and <strong>tbody<\/strong>, and must use <strong>th<\/strong> tags to indicate column and row headers.<\/p>\n<h2>Responsive Tables<\/h2>\n<p>If your <strong>table<\/strong> can be simplified as a series of rows, you can use the class &#8220;responsive-table&#8221; to have the content re-arrange itself on mobile devices.<\/p>\n<table class=\"responsive-table\">\n<thead>\n<tr>\n<th>Column 1<\/th>\n<th>Column 2<\/th>\n<th>Column 3<\/th>\n<th>Column 4<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Data 1,1<\/td>\n<td>Data 2,1<\/td>\n<td>Data 3,1<\/td>\n<td>Data 4,1<\/td>\n<\/tr>\n<tr>\n<td>Data 1,2<\/td>\n<td>Data 2,2<\/td>\n<td>Data 3,2<\/td>\n<td>Data 4,2<\/td>\n<\/tr>\n<tr>\n<td>Data 1,3<\/td>\n<td>Data 2,3<\/td>\n<td>Data 3,3<\/td>\n<td>Data 4,3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Code Sample<\/h3>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\r\n&amp;lt;table class=&quot;responsive-table&quot;&amp;gt;\r\n&amp;lt;thead&amp;gt;\r\n&amp;lt;tr&amp;gt;\r\n&amp;lt;th scope=&quot;col&quot;&amp;gt;Column 1&amp;lt;\/th&amp;gt;\r\n&amp;lt;th scope=&quot;col&quot;&amp;gt;Column 2&amp;lt;\/th&amp;gt;\r\n&amp;lt;th scope=&quot;col&quot;&amp;gt;Column 3&amp;lt;\/th&amp;gt;\r\n&amp;lt;th scope=&quot;col&quot;&amp;gt;Column 4&amp;lt;\/th&amp;gt;\r\n&amp;lt;\/tr&amp;gt;\r\n&amp;lt;\/thead&amp;gt;\r\n&amp;lt;tbody&amp;gt;\r\n&amp;lt;tr&amp;gt;\r\n&amp;lt;td&amp;gt;Data 1,1&amp;lt;\/td&amp;gt;\r\n&amp;lt;td&amp;gt;Data 2,1&amp;lt;\/td&amp;gt;\r\n&amp;lt;td&amp;gt;Data 3,1&amp;lt;\/td&amp;gt;\r\n&amp;lt;td&amp;gt;Data 4,1&amp;lt;\/td&amp;gt;\r\n&amp;lt;\/tr&amp;gt;\r\n&amp;lt;tr&amp;gt;\r\n&amp;lt;td&amp;gt;Data 1,2&amp;lt;\/td&amp;gt;\r\n&amp;lt;td&amp;gt;Data 2,2&amp;lt;\/td&amp;gt;\r\n&amp;lt;td&amp;gt;Data 3,2&amp;lt;\/td&amp;gt;\r\n&amp;lt;td&amp;gt;Data 4,2&amp;lt;\/td&amp;gt;\r\n&amp;lt;\/tr&amp;gt;\r\n&amp;lt;tr&amp;gt;\r\n&amp;lt;td&amp;gt;Data 1,3&amp;lt;\/td&amp;gt;\r\n&amp;lt;td&amp;gt;Data 2,3&amp;lt;\/td&amp;gt;\r\n&amp;lt;td&amp;gt;Data 3,3&amp;lt;\/td&amp;gt;\r\n&amp;lt;td&amp;gt;Data 4,3&amp;lt;\/td&amp;gt;\r\n&amp;lt;\/tr&amp;gt;\r\n&amp;lt;\/tbody&amp;gt;\r\n&amp;lt;\/table&amp;gt;\r\n\r\n<\/pre>\n<h2 id=\"sortable\">Sortable Tables<\/h2>\n<p>Using the class <strong>sortable<\/strong> you can create a table where the visitor can sort by any of the columns. In the column headings you can use the class name <strong>sort-default<\/strong> to choose which column the table will be sorted on after page load. If you don&#8217;t set a default, the table will be sorted by the first column.<\/p>\n<p>You can also add the class name <strong>desc<\/strong> to reverse the order of the initial sort column.<\/p>\n<p>If you set <strong>data-column-type<\/strong> to <strong>date<\/strong> the script will attempt to parse the column&#8217;s contents as dates. (If the column&#8217;s contents aren&#8217;t valid dates, it&#8217;ll default back to strings.)<\/p>\n<p><em>You cannot use both the <strong>sortable<\/strong> and <strong>responsive-table<\/strong> classes at the same time.<\/em><\/p>\n<table class=\"sortable\">\n<thead>\n<tr>\n<th>Rank<\/th>\n<th>Sales (Millions)<\/th>\n<th>Album<\/th>\n<th>Artist<\/th>\n<th scope=\"col\" data-column-type=\"date\">Year<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>47<\/td>\n<td>Thriller<\/td>\n<td>Michael Jackson<\/td>\n<td>1982<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>41<\/td>\n<td>Their Greatest Hits 1971-1975<\/td>\n<td>The Eagles<\/td>\n<td>1976<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>32<\/td>\n<td>Hotel California<\/td>\n<td>The Eagles<\/td>\n<td>1976<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>29<\/td>\n<td>Come on Over<\/td>\n<td>Shania Twain<\/td>\n<td>1997<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>29<\/td>\n<td>Led Zeppelin IV<\/td>\n<td>Led Zeppelin<\/td>\n<td>1971<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>You can also use <strong>data-column-type=&#8221;weekday&#8221;<\/strong> to sort by weekday.<\/p>\n<table class=\"sortable\">\n<thead>\n<tr>\n<th data-column-type=\"weekday\">Weekday<\/th>\n<th>ÌÇÐÄvlog<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Monday<\/td>\n<td>Meatloaf<\/td>\n<\/tr>\n<tr>\n<td>Tuesday<\/td>\n<td>Chicken Pot Pie<\/td>\n<\/tr>\n<tr>\n<td>Wednesday<\/td>\n<td>Macaroni &amp; Cheese<\/td>\n<\/tr>\n<tr>\n<td>Thursday<\/td>\n<td>Pork Chops<\/td>\n<\/tr>\n<tr>\n<td>Friday<\/td>\n<td>Pizza<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Code Samples<\/h3>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&amp;lt;table class=&quot;sortable&quot;&amp;gt;\r\n\t&amp;lt;thead&amp;gt;\r\n\t\t&amp;lt;tr&amp;gt;\r\n\t\t\t&amp;lt;th class=&quot;sort-default&quot;&amp;gt;Rank&amp;lt;\/th&amp;gt;\r\n\t\t\t&amp;lt;th&amp;gt;Sales (Millions)&amp;lt;\/th&amp;gt;\r\n\t\t\t&amp;lt;th&amp;gt;Album&amp;lt;\/th&amp;gt;\r\n\t\t\t&amp;lt;th&amp;gt;Artist&amp;lt;\/th&amp;gt;\r\n\t\t\t&amp;lt;th data-column-type=&quot;date&quot;&amp;gt;Year&amp;lt;\/th&amp;gt;\r\n\t\t&amp;lt;\/tr&amp;gt;\r\n\t&amp;lt;\/thead&amp;gt;\r\n\t&amp;lt;tbody&amp;gt;\r\n\t\t&amp;lt;tr&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;1&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;47&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;Thriller&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;Michael Jackson&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;1982&amp;lt;\/td&amp;gt;\r\n\t\t&amp;lt;\/tr&amp;gt;\r\n\t\t&amp;lt;tr&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;2&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;41&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;Their Greatest Hits 1971-1975&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;The Eagles&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;1976&amp;lt;\/td&amp;gt;\r\n\t\t&amp;lt;\/tr&amp;gt;\r\n\t\t&amp;lt;tr&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;3&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;32&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;Hotel California&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;The Eagles&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;1976&amp;lt;\/td&amp;gt;\r\n\t\t&amp;lt;\/tr&amp;gt;\r\n\t\t&amp;lt;tr&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;4&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;29&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;Come on Over&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;Shania Twain&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;1997&amp;lt;\/td&amp;gt;\r\n\t\t&amp;lt;\/tr&amp;gt;\r\n\t\t&amp;lt;tr&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;5&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;29&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;Led Zeppelin IV&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;Led Zeppelin&amp;lt;\/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;1971&amp;lt;\/td&amp;gt;\r\n\t\t&amp;lt;\/tr&amp;gt;\r\n\t&amp;lt;\/tbody&amp;gt;\r\n&amp;lt;\/table&amp;gt;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&amp;lt;table class=&quot;sortable&quot;&amp;gt;\r\n  &amp;lt;thead&amp;gt;\r\n    &amp;lt;tr&amp;gt;\r\n      &amp;lt;th data-column-type=&quot;weekday&quot;&amp;gt;Weekday&amp;lt;\/th&amp;gt;\r\n      &amp;lt;th&amp;gt;ÌÇÐÄvlog&amp;lt;\/th&amp;gt;\r\n    &amp;lt;\/tr&amp;gt;\r\n  &amp;lt;\/thead&amp;gt;\r\n  &amp;lt;tbody&amp;gt;\r\n    &amp;lt;tr&amp;gt;\r\n      &amp;lt;td&amp;gt;Monday&amp;lt;\/td&amp;gt;\r\n      &amp;lt;td&amp;gt;Meatloaf&amp;lt;\/td&amp;gt;\r\n    &amp;lt;\/tr&amp;gt;\r\n    &amp;lt;tr&amp;gt;\r\n      &amp;lt;td&amp;gt;Tuesday&amp;lt;\/td&amp;gt;\r\n      &amp;lt;td&amp;gt;Chicken Pot Pie&amp;lt;\/td&amp;gt;\r\n    &amp;lt;\/tr&amp;gt;\r\n    &amp;lt;tr&amp;gt;\r\n      &amp;lt;td&amp;gt;Wednesday&amp;lt;\/td&amp;gt;\r\n      &amp;lt;td&amp;gt;Macaroni &amp;amp;amp; Cheese&amp;lt;\/td&amp;gt;\r\n    &amp;lt;\/tr&amp;gt;\r\n    &amp;lt;tr&amp;gt;\r\n      &amp;lt;td&amp;gt;Thursday&amp;lt;\/td&amp;gt;\r\n      &amp;lt;td&amp;gt;Pork Chops&amp;lt;\/td&amp;gt;\r\n    &amp;lt;\/tr&amp;gt;\r\n    &amp;lt;tr&amp;gt;\r\n      &amp;lt;td&amp;gt;Friday&amp;lt;\/td&amp;gt;\r\n      &amp;lt;td&amp;gt;Pizza&amp;lt;\/td&amp;gt;\r\n    &amp;lt;\/tr&amp;gt;\r\n  &amp;lt;\/tbody&amp;gt;\r\n&amp;lt;\/table&amp;gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The table tag is intended to hold tabulated data. Unlike a list or a paragraph, data in a table is given additional meaning by its placement within the row\/column structure. Never use a table to control page design layout. If you want to arrange items in rows and columns, see Rows and Columns. Tables are [&hellip;]<\/p>\n","protected":false},"author":411,"featured_media":3785,"parent":3510,"menu_order":4,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"footnotes":""},"class_list":["post-3519","page","type-page","status-publish","has-post-thumbnail","hentry"],"_links":{"self":[{"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/pages\/3519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/users\/411"}],"replies":[{"embeddable":true,"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/comments?post=3519"}],"version-history":[{"count":2,"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/pages\/3519\/revisions"}],"predecessor-version":[{"id":3735,"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/pages\/3519\/revisions\/3735"}],"up":[{"embeddable":true,"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/pages\/3510"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/media\/3785"}],"wp:attachment":[{"href":"https:\/\/www.montclair.edu\/university-communications\/wp-json\/wp\/v2\/media?parent=3519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}