{"id":8089,"date":"2022-09-27T04:19:27","date_gmt":"2022-09-27T04:19:27","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=8089"},"modified":"2022-09-27T04:19:27","modified_gmt":"2022-09-27T04:19:27","slug":"html-tables","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/09\/27\/html-tables\/","title":{"rendered":"HTML Tables"},"content":{"rendered":"\n<p>In HTML, you can create tables for your website using the\u00a0&lt;table>\u00a0tag in conjunction with the\u00a0&lt;tr>,\u00a0&lt;td>\u00a0and\u00a0&lt;th>\u00a0tags.<\/p>\n\n\n\n<p>The HTML tables allow displaying the data (e.g. image, text, link) in columns and rows of cells. Table rows can be grouped into a head, foot, and body sections through the\u00a0&lt;thead>,\u00a0&lt;tfoot>\u00a0and\u00a0&lt;tbody>\u00a0elements, respectively.<\/p>\n\n\n\n<p>In HTML5, we can place &lt;tfoot> either before or after &lt;tbody> tag. They must come after any\u00a0&lt;caption>,\u00a0&lt;colgroup>, and &lt;thead> elements.<\/p>\n\n\n\n<p>Most of the attributes of the &lt;table&gt; element are not used in HTML5. If you want to style the appearance of the table, you can use CSS instead.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"spanning-multiple-rows-and-columns-2\">Spanning Multiple Rows and Columns<\/h2>\n\n\n\n<p>It is possible to extend rows and columns of a table across many other rows and columns.<\/p>\n\n\n\n<p>Commonly, a table cell cannot pass into the space, which is below or above another cell. But, if you want to span several rows or columns in a table, you can use the&nbsp;colspan&nbsp;or&nbsp;rowspan&nbsp;attributes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"adding-captions-to-tables-4\">Adding Captions to Tables<\/h2>\n\n\n\n<p>You can use the &lt;caption> element to specify a caption for tables. It should be placed immediately after the opening &lt;table> tag. By default, the caption will be at the top of the table, but its position can be changed with the\u00a0CSS caption-side\u00a0property.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"syntax-6\">Syntax<\/h2>\n\n\n\n<p>The &lt;table&gt; tag comes in pairs. The content is written between the opening &lt;table&gt; and the closing &lt;\/table&gt; tags.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-table-gt-tag-8\">Example of the HTML &lt;table&gt; tag:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;style&gt;\n      table, th, td {\n        border: 1px solid #666;\n      }\n    &lt;\/style&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;table style=\"width:80%;\"&gt;\n      &lt;tr&gt;\n        &lt;th&gt;Month&lt;\/th&gt;\n        &lt;th&gt;Date&lt;\/th&gt;\n      &lt;\/tr&gt;\n      &lt;tr&gt;\n        &lt;td&gt;January&lt;\/td&gt;\n        &lt;td&gt;10.01.2014&lt;\/td&gt;\n      &lt;\/tr&gt;\n      &lt;tr&gt;\n        &lt;td&gt;February&lt;\/td&gt;\n        &lt;td&gt;10.01.2014&lt;\/td&gt;\n      &lt;\/tr&gt;\n    &lt;\/table&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"result-10\">Result<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Month<\/th><th>Date<\/th><\/tr><tr><td>January<\/td><td>10.01.2014<\/td><\/tr><tr><td>February<\/td><td>10.01.2014<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>In the given example, we use the &lt;table&gt; tag to create a table. Then, we use the &lt;tr&gt; tag to divide the table into rows. The &lt;th&gt; tag is used for the table header cells, where the title is written. In other words, the table row is divided into headings. The &lt;td&gt; tag is used for table cells where the information is written.<\/p>\n\n\n\n<p>If you want to show the heading in one cell, you can use the&nbsp;colspan&nbsp;attribute.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-table-gt-tag-with-the-span-class-attribute-colspan-span-attribute-12\">Example of the HTML &lt;table&gt; tag with the&nbsp;colspan&nbsp;attribute:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;style&gt;\n      table, th, td {\n        border: 1px solid #666;\n      }\n    &lt;\/style&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;table style=\"width:80%;\"&gt;\n      &lt;tr&gt;\n        &lt;th colspan=\"2\"&gt;Month and Date&lt;\/th&gt;\n      &lt;\/tr&gt;\n      &lt;tr&gt;\n        &lt;td&gt;January&lt;\/td&gt;\n        &lt;td&gt;10.01.2014&lt;\/td&gt;\n      &lt;\/tr&gt;\n      &lt;tr&gt;\n        &lt;td&gt;February&lt;\/td&gt;\n        &lt;td&gt;10.01.2014&lt;\/td&gt;\n      &lt;\/tr&gt;\n    &lt;\/table&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"result-14\">Result<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Month and Date<\/th><\/tr><tr><td>January<\/td><td>10.01.2014<\/td><\/tr><tr><td>February<\/td><td>10.01.2014<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The same can be done with the rows, but using the&nbsp;rowspan&nbsp;attribute.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-table-gt-tag-with-the-span-class-attribute-rowspan-span-attribute-16\">Example of the HTML &lt;table&gt; tag with the&nbsp;rowspan&nbsp;attribute:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;style&gt;\n      table, th, td {\n        border: 1px solid #666;\n      }\n    &lt;\/style&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;table style=\"width:80%;\"&gt;\n      &lt;tr&gt;\n        &lt;th&gt;Month&lt;\/th&gt;\n        &lt;th&gt;Date&lt;\/th&gt;\n      &lt;\/tr&gt;\n      &lt;tr&gt;\n        &lt;td&gt;January&lt;\/td&gt;\n        &lt;td rowspan=\"2\"&gt;10.01.2014&lt;\/td&gt;\n      &lt;\/tr&gt;\n      &lt;tr&gt;\n        &lt;td&gt;February&lt;\/td&gt;\n      &lt;\/tr&gt;\n    &lt;\/table&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"result-18\">Result<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Month<\/th><th>Date<\/th><\/tr><tr><td>January<\/td><td>10.01.2014<\/td><\/tr><tr><td>February<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n","protected":false},"excerpt":{"rendered":"<p>In HTML, you can create tables for your website using the\u00a0&lt;table>\u00a0tag in conjunction with the\u00a0&lt;tr>,\u00a0&lt;td>\u00a0and\u00a0&lt;th>\u00a0tags. The HTML tables allow displaying the data (e.g. image, text, link) in columns and rows of cells. Table rows can be grouped into a head, foot, and body sections through the\u00a0&lt;thead>,\u00a0&lt;tfoot>\u00a0and\u00a0&lt;tbody>\u00a0elements, respectively. In HTML5, we can place &lt;tfoot> either before [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[285],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/8089"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=8089"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/8089\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=8089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=8089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=8089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}