{"id":4813,"date":"2017-11-29T04:24:45","date_gmt":"2017-11-29T04:24:45","guid":{"rendered":"http:\/\/a1webdesignteam.com\/blog\/?p=4813"},"modified":"2017-11-29T04:24:45","modified_gmt":"2017-11-29T04:24:45","slug":"tables-rowspan-and-colspan","status":"publish","type":"post","link":"https:\/\/a1webdesignteam.com\/blog\/tables-rowspan-and-colspan\/","title":{"rendered":"Tables rowspan and colspan"},"content":{"rendered":"<header><strong>Tables<\/strong>\u00a0may have seemed complicated enough\u00a0in the HTML Beginner Tutorial. It can be quite difficult to visualize a two-dimensional grid from one-dimensional lines of code.<\/p>\n<p>Well, it gets trickier. All thanks to the\u00a0<code>rowspan<\/code>and\u00a0<code>colspan<\/code>\u00a0attributes. Those bastards.<\/p>\n<\/header>\n<section>The following code is similar to that in\u00a0the Tables page of the HTML Beginner Tutorial:<\/p>\n<pre class=\" language-html\"><code class=\"oldLang  language-html\">\r\n<span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>table<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n    <span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>tr<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n        <span class=\"token tag\"><strong><span class=\"token punctuation\">&lt;<\/span>th<span class=\"token punctuation\">&gt;<\/span><\/strong><\/span>Column 1 heading<span class=\"token tag\"><strong><span class=\"token punctuation\">&lt;\/<\/span>th<span class=\"token punctuation\">&gt;<\/span><\/strong><\/span>\r\n        <span class=\"token tag\"><strong><span class=\"token punctuation\">&lt;<\/span>th<span class=\"token punctuation\">&gt;<\/span><\/strong><\/span>Column 2 heading<span class=\"token tag\"><strong><span class=\"token punctuation\">&lt;\/<\/span>th<span class=\"token punctuation\">&gt;<\/span><\/strong><\/span>\r\n        <span class=\"token tag\"><strong><span class=\"token punctuation\">&lt;<\/span>th<span class=\"token punctuation\">&gt;<\/span><\/strong><\/span>Column 3 heading<span class=\"token tag\"><strong><span class=\"token punctuation\">&lt;\/<\/span>th<span class=\"token punctuation\">&gt;<\/span><\/strong><\/span>\r\n    <span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>tr<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n    <span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>tr<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n        <span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>td<span class=\"token punctuation\">&gt;<\/span><\/span>Row 2, cell 1<span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>td<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n        <span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>td <strong><span class=\"token attr-name\">colspan<\/span><span class=\"token attr-value\"><span class=\"token punctuation\">=<\/span><span class=\"token punctuation\">\"<\/span>2<span class=\"token punctuation\">\"<\/span><\/span><\/strong><span class=\"token punctuation\">&gt;<\/span><\/span>Row 2, cell 2, also spanning Row 2, cell 3<span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>td<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n    <span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>tr<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n    <span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>tr<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n        <span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>td <strong><span class=\"token attr-name\">rowspan<\/span><span class=\"token attr-value\"><span class=\"token punctuation\">=<\/span><span class=\"token punctuation\">\"<\/span>2<span class=\"token punctuation\">\"<\/span><\/span><\/strong><span class=\"token punctuation\">&gt;<\/span><\/span>Row 3, cell 1, also spanning Row 4, cell 1<span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>td<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n        <span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>td<span class=\"token punctuation\">&gt;<\/span><\/span>Row 3, cell 2<span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>td<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n        <span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>td<span class=\"token punctuation\">&gt;<\/span><\/span>Row 3, cell 3<span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>td<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n    <span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>tr<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n    <span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>tr<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n        <span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>td<span class=\"token punctuation\">&gt;<\/span><\/span>Row 4, cell 2<span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>td<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n        <span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>td<span class=\"token punctuation\">&gt;<\/span><\/span>Row 4, cell 3<span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>td<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n    <span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>tr<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n<span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>table<span class=\"token punctuation\">&gt;<\/span><\/span>\r\n<\/code><\/pre>\n<div id=\"bsap_1305815\" class=\"bsap bsap_1305815\" data-serve=\"CVAD55QE\"><\/div>\n<h2>Header cells<\/h2>\n<p>The first difference is that the\u00a0<a class=\"acode\" href=\"http:\/\/htmldog.com\/references\/html\/tags\/td\/\"><code>td<\/code><\/a>\u00a0tags of the first row have been replaced with\u00a0<a class=\"acode\" href=\"http:\/\/htmldog.com\/references\/html\/tags\/th\/\"><code>th<\/code><\/a>\u00a0tags. Whereas a\u00a0<a class=\"acode\" href=\"http:\/\/htmldog.com\/references\/html\/tags\/td\/\"><code>td<\/code><\/a>\u00a0is a standard\u00a0<strong>data<\/strong>\u00a0cell,\u00a0<a class=\"acode\" href=\"http:\/\/htmldog.com\/references\/html\/tags\/th\/\"><code>th<\/code><\/a>\u00a0is a\u00a0<strong>header<\/strong>\u00a0cell. As with\u00a0<a class=\"acode\" href=\"http:\/\/htmldog.com\/references\/html\/tags\/td\/\"><code>td<\/code><\/a>\u00a0elements, these must be enclosed inside\u00a0<a class=\"acode\" href=\"http:\/\/htmldog.com\/references\/html\/tags\/tr\/\"><code>tr<\/code><\/a>\u00a0elements.<\/p>\n<h2>Spanning columns and rows<\/h2>\n<p><code>colspan<\/code>\u00a0and\u00a0<code>rowspan<\/code>\u00a0attributes have also been used in some of the\u00a0<a class=\"acode\" href=\"http:\/\/htmldog.com\/references\/html\/tags\/td\/\"><code>td<\/code><\/a>tags. If you look at this code in a browser, you will see that on the second row there are now two cells instead of three, the second cell spanning the second and third column. The\u00a0<code>colspan<\/code>\u00a0attribute, which means \u201ccolumn span\u201d will span the cell over the number of cells that is specified. This means, in this example, that there is no need for a third\u00a0<a class=\"acode\" href=\"http:\/\/htmldog.com\/references\/html\/tags\/td\/\"><code>td<\/code><\/a>\u00a0element \u2014 two cells are\u00a0<strong>merged<\/strong>\u00a0into one.<\/p>\n<aside class=\"foodC\">\n<div id=\"bsap_1305864\" class=\"bsap bsap_1305864\" data-serve=\"CVADE23N\">The\u00a0<code>rowspan<\/code>\u00a0attribute is similar to\u00a0<code>colspan<\/code>, except, obviously, it will span across rows rather than columns. Again, the cells that it spans should be removed. In this example, because it spans over the fourth row, there are only two cells in that row.<\/div>\n<\/aside>\n<p>As with the simpler 3&#215;4, 12-cell table, the numbers on these tables with merged cells should also add up. Although there are only 10 cells in this example, there are 2 spans.<\/p>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>Tables\u00a0may have seemed complicated enough\u00a0in the HTML Beginner Tutorial. It can be quite difficult to visualize a two-dimensional grid from one-dimensional lines of code. Well, it gets trickier. All thanks to the\u00a0rowspanand\u00a0colspan\u00a0attributes. Those bastards. The following code is similar to that in\u00a0the Tables page of the HTML Beginner Tutorial: &lt;table&gt; &lt;tr&gt; &lt;th&gt;Column 1 heading&lt;\/th&gt; &lt;th&gt;Column [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4815,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0},"categories":[22],"tags":[51,119,132],"_links":{"self":[{"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/posts\/4813"}],"collection":[{"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/comments?post=4813"}],"version-history":[{"count":0,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/posts\/4813\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/media\/4815"}],"wp:attachment":[{"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/media?parent=4813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/categories?post=4813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/a1webdesignteam.com\/blog\/wp-json\/wp\/v2\/tags?post=4813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}