{"id":233,"date":"2011-11-01T19:22:01","date_gmt":"2011-11-02T02:22:01","guid":{"rendered":"http:\/\/rockblot.wordpress.com\/?p=233"},"modified":"2011-11-01T19:22:01","modified_gmt":"2011-11-02T02:22:01","slug":"using-html-to-create-a-table-in-your-wp-article","status":"publish","type":"post","link":"https:\/\/www.rockblotter.com\/DijaKnowThat\/using-html-to-create-a-table-in-your-wp-article\/","title":{"rendered":"Using HTML to Create a Table in Your WP Article"},"content":{"rendered":"<p>Have you ever wanted to present some data in a table format in your wordpress document, but you&#8217;re not an HTML whiz-kid? \u00a0 The free version of WP doesn&#8217;t have a widget to help you create a table, so that means you&#8217;ll need to use HTML code to create that table. \u00a0Let&#8217;s see if I can simplify for you how you can do that within the HTML window to create the framework for your table. Once the framework is built, you can return to the VISUAL window to fill in the data.<\/p>\n<p>HTML uses what I&#8217;ll call START and END tags. \u00a0You&#8217;ll need to &#8216;wrap&#8217; your table between &lt;table&gt; and &lt;\/table&gt; tags. \u00a0Within those tags, you need to start the body of your table with a &lt;tbody&gt; tag and end the body of your table with a &lt;\/tbody&gt; tag.<\/p>\n<blockquote><p>&lt;table&gt;<br \/>\n&lt;tbody&gt;<br \/>\n<span style=\"color:#0000ff;\">\u00a0 \u00a0this is where you&#8217;ll put all your rows of columns (we&#8217;ll talk about codes for that next)<\/span><br \/>\n&lt;\/tbody&gt;<br \/>\n&lt;\/table&gt;<\/p><\/blockquote>\n<p>Now that you&#8217;ve got that set up, you&#8217;ll create your rows and the columns within those rows. \u00a0If you were using a\u00a0word-processor\u00a0to create a table, you&#8217;d start a row within the table by typing something to be displayed in column 1, then tab to where column 2 would begin, type something, and then tab to where column 3 would begin, and type something, etc. \u00a0HTML uses START &lt;tr&gt; and END &lt;\/tr&gt; tags to identify where each ROW begins and ends. \u00a0Between &lt;tbody&gt; and &lt;\/tbody&gt; tags you&#8217;ll create START &lt;td&gt; and END &lt;\/td&gt; tags to identify where data for each column within that row starts and ends. \u00a0For example, let&#8217;s say we want to create a ROW that has 3 columns of data. \u00a0Here&#8217;s what that framework would look like:<\/p>\n<blockquote><p>&lt;tr&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;\/tr&gt;<\/p><\/blockquote>\n<p>The &lt;tr&gt; and &lt;\/tr&gt; tags start and end the row. \u00a0The &lt;td&gt; and &lt;\/td&gt; tag starts and ends a column within that row. \u00a0If you want to create more rows, just repeat that structure. \u00a0For example, let&#8217;s say \u00a0you want to create a table that has four rows and three columns. \u00a0This is what the HTML code would look like for that simple table:<\/p>\n<blockquote><p>&lt;table&gt;<br \/>\n&lt;tbody&gt;<\/p>\n<p>&lt;tr&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;\/tr&gt;<\/p>\n<p>&lt;tr&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;\/tr&gt;<\/p>\n<p>&lt;tr&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;\/tr&gt;<\/p>\n<p>&lt;tr&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;td&gt; &lt;\/td&gt;<br \/>\n&lt;\/tr&gt;<\/p>\n<p>&lt;\/tbody&gt;<br \/>\n&lt;\/table&gt;<\/p><\/blockquote>\n<p>The framework above will create a table that has four rows with three columns. \u00a0If you need more rows or more columns, just increase the number of row tags and\/or column tags in your framework.<\/p>\n<blockquote>\n<table>\n<tbody>\n<tr>\n<td><span style=\"color:#ffffff;\">&#8230;&#8230;&#8230;<\/span><\/td>\n<td><span style=\"color:#ffffff;\">&#8230;&#8230;&#8230;<\/span><\/td>\n<td><span style=\"color:#ffffff;\">&#8230;&#8230;&#8230;<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#ffffff;\">\u00a0&#8230;..\u00a0<\/span><\/td>\n<td><span style=\"color:#ffffff;\">\u00a0&#8230;..<\/span><\/td>\n<td><span style=\"color:#ffffff;\">\u00a0&#8230;..<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#ffffff;\">\u00a0&#8230;..<\/span><\/td>\n<td><span style=\"color:#ffffff;\">\u00a0&#8230;..<\/span><\/td>\n<td><span style=\"color:#ffffff;\">\u00a0&#8230;..<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#ffffff;\">\u00a0&#8230;..<\/span><\/td>\n<td><span style=\"color:#ffffff;\">\u00a0&#8230;..<\/span><\/td>\n<td><span style=\"color:#ffffff;\">\u00a0&#8230;..<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/blockquote>\n<p>Once you click on the VISUAL tab and begin typing data in the table cells, the cells will adjust themselves to accommodate the data you&#8217;re typing into the cells. \u00a0You may not want the automatic adjustments to the overall table width or the column widths. \u00a0You may instead want to fix the width of the columns and force the data to word-wrap within the various column cells.<\/p>\n<p><strong>SETTING OVERALL \u00a0&lt;TABLE&gt; \u00a0ATTRIBUTES<\/strong><\/p>\n<p>If you want the table to be a fixed or flexible width on the screen, you&#8217;ll need to add an attribute to the &lt;table&gt; tag:<\/p>\n<ul>\n<li>The syntax of the table width attribute is <span style=\"color:#006699;\"><strong>&lt;table width=&#8221;<em>value<\/em>&#8220;&gt;<\/strong><\/span><br \/>\n<table width=\"75%\">\n<tbody>\n<tr>\n<td align=\"center\" width=\"15%\"><strong>Value<\/strong><\/td>\n<td align=\"left\" width=\"85%\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td align=\"center\"><em>pixels<\/em><\/td>\n<td>Sets the width in pixels (example: width=&#8221;50&#8243;)<\/td>\n<\/tr>\n<tr>\n<td align=\"center\"><em>%<\/em><\/td>\n<td>Sets the width in percent of the surrounding element (example: width=&#8221;50%&#8221;)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<p>If you want the table to have or not have a border, you&#8217;ll need to set a border attribute within the &lt;table&gt; tag:<\/p>\n<ul>\n<li>The syntax of the table border attribute is<span style=\"color:#006699;\">\u00a0<strong>&lt;table border=&#8221;<em>value<\/em>&#8220;&gt;<\/strong><\/span><br \/>\n<table width=\"75%\">\n<tbody>\n<tr>\n<td align=\"center\" width=\"15%\"><strong>Value<\/strong><\/td>\n<td align=\"left\" width=\"85%\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td align=\"center\"><em>pixels<\/em><\/td>\n<td>Specifies the border width as a number<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<p>If you need to provide some\u00a0space between the cell wall border and the cell content, you might want to create some &#8216;cell padding.&#8217;<\/p>\n<ul>\n<li>The syntax of the cell padding attribute is\u00a0<span style=\"color:#006699;\"><strong>&lt;table border=&#8221;<em>value<\/em>&#8220;&gt;<br \/>\n<\/strong><\/span><\/p>\n<table width=\"75%\">\n<tbody>\n<tr>\n<td style=\"text-align:center;\" align=\"left\" width=\"15%\"><strong>Value<\/strong><\/td>\n<td align=\"left\" width=\"85%\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td align=\"center\"><em>pixels<\/em><\/td>\n<td>The space between the cell wall and the cell content<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<p><strong><br \/>\nSETTING INDIVIDUAL TABLE CELL ATTRIBUTES<\/strong><\/p>\n<p>You can also modify data within the column-rows. \u00a0You can modify the column width, vertical alignment of the data and the horizontal alignment by modifying the attributes of the &lt;td&gt; tag.<\/p>\n<ul style=\"padding-left:30px;\">\n<li>The syntax of the column width attribute is <span style=\"color:#006699;\"><strong>&lt;td width=<em>&#8220;value&#8221;<\/em>&gt;<\/strong><\/span>. \u00a0The value attribute can be any number of pixels or a percentage of screen width (and needs to be enclosed in parentheses). \u00a0Plus, to simplify things, you technically only need to include the width attribute definitions in the first row of the table. \u00a0All rows that follow the first row will use the same widths as are defined in the first row of the table.<\/li>\n<li>The syntax of the table cell horizontal alignment is <strong><span style=\"color:#006699;\">&lt;td align=&#8221;<em>value<\/em>&#8220;&gt;<\/span>.<\/strong><br \/>\n<table width=\"75%\">\n<tbody>\n<tr>\n<td style=\"text-align:center;\" align=\"left\" width=\"15%\"><strong>Value<\/strong><\/td>\n<td align=\"left\" width=\"85%\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td align=\"center\">left<\/td>\n<td>Left-align content (default for td elements)<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">right<\/td>\n<td>Right-align content<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">center<\/td>\n<td>Center-align content<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">justify<\/td>\n<td>Stretches the lines so that each line has equal width (like in newspapers and magazines)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;\">char<\/td>\n<td>Align the content to a specific character<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>The syntax of the table cell vertical \u00a0alignment is\u00a0<span style=\"color:#006699;\"><strong>&lt;td valign=&#8221;<em>value<\/em>&#8220;&gt;<\/strong><\/span>.<br \/>\n<table width=\"75%\">\n<tbody>\n<tr>\n<td align=\"center\" width=\"15%\"><strong>Value<\/strong><\/td>\n<td align=\"left\" width=\"85%\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td align=\"center\">top<\/td>\n<td>Top-align content<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">middle<\/td>\n<td>Center-align content<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center;\">bottom<\/td>\n<td>Bottom-align content<\/td>\n<\/tr>\n<tr>\n<td align=\"center\" valign=\"top\">baseline<\/td>\n<td>The baseline is the &#8220;imaginary line&#8221; which most letters &#8220;sit&#8221; on, in a line of text. The baseline value sets the row so that all the table data share the same baseline. Often this has the same effect as the bottom value. However, if the fonts are in different sizes, baseline looks better. Look at the illustration below<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<p>So, let&#8217;s take a look at how we might want to create a 3-row, 3-column table with equal widths of 125 pixels and cell padding of 2 pixels, with table cells that are top-aligned.<\/p>\n<blockquote><p>&lt;table width=&#8221;98%&#8221; border=&#8221;0&#8243; cellpadding=&#8221;2&#8243;&gt;<br \/>\n&lt;tbody&gt;<br \/>\n&lt;tr&gt;<br \/>\n&lt;td valign=&#8221;top&#8221; width=&#8221;125&#8243;&gt;&lt;\/td&gt;<br \/>\n&lt;td valign=&#8221;top&#8221; width=&#8221;125&#8243;&gt;&lt;\/td&gt;<br \/>\n&lt;td valign=&#8221;top&#8221; width=&#8221;125&#8243;&gt;&lt;\/td&gt;<br \/>\n&lt;\/tr&gt;<br \/>\n&lt;tr&gt;<br \/>\n&lt;td valign=&#8221;top&#8221;&gt;&lt;\/td&gt;<br \/>\n&lt;td valign=&#8221;top&#8221;&gt;&lt;\/td&gt;<br \/>\n&lt;td valign=&#8221;top&#8221;&gt;&lt;\/td&gt;<br \/>\n&lt;\/tr&gt;<br \/>\n&lt;tr&gt;<br \/>\n&lt;td valign=&#8221;top&#8221;&gt;&lt;\/td&gt;<br \/>\n&lt;td valign=&#8221;top&#8221;&gt;&lt;\/td&gt;<br \/>\n&lt;td valign=&#8221;top&#8221;&gt;&lt;\/td&gt;<br \/>\n&lt;\/tr&gt;<br \/>\n&lt;\/tbody&gt;<br \/>\n&lt;\/table&gt;<\/p><\/blockquote>\n<p>Once that HTML-Table code is created or pasted into the HTML pane, all that remains is to add the actual data in each of the table cells. Adding that data, however, can be done from the VISUAL pane.<\/p>\n<p>Hope this post helps you create a table the next time you need one.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever wanted to present some data in a table format in your wordpress document, but you&#8217;re not an HTML whiz-kid? \u00a0 The free version of WP doesn&#8217;t have a widget to help you create a table, so that means you&#8217;ll need to use HTML code to create that table. \u00a0Let&#8217;s see if I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":609,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[5],"tags":[],"class_list":["post-233","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-html"],"_links":{"self":[{"href":"https:\/\/www.rockblotter.com\/DijaKnowThat\/wp-json\/wp\/v2\/posts\/233","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rockblotter.com\/DijaKnowThat\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rockblotter.com\/DijaKnowThat\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rockblotter.com\/DijaKnowThat\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rockblotter.com\/DijaKnowThat\/wp-json\/wp\/v2\/comments?post=233"}],"version-history":[{"count":0,"href":"https:\/\/www.rockblotter.com\/DijaKnowThat\/wp-json\/wp\/v2\/posts\/233\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rockblotter.com\/DijaKnowThat\/wp-json\/wp\/v2\/media\/609"}],"wp:attachment":[{"href":"https:\/\/www.rockblotter.com\/DijaKnowThat\/wp-json\/wp\/v2\/media?parent=233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rockblotter.com\/DijaKnowThat\/wp-json\/wp\/v2\/categories?post=233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rockblotter.com\/DijaKnowThat\/wp-json\/wp\/v2\/tags?post=233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}