{"id":245,"date":"2011-05-20T12:07:43","date_gmt":"2011-05-20T10:07:43","guid":{"rendered":"http:\/\/hen.co.za\/blog\/?p=245"},"modified":"2011-05-20T12:07:43","modified_gmt":"2011-05-20T10:07:43","slug":"center-an-html-table","status":"publish","type":"post","link":"https:\/\/hen.co.za\/blog\/2011\/05\/center-an-html-table\/","title":{"rendered":"Center an html table"},"content":{"rendered":"<p>Quick tip.<\/p>\n<p>Since css is the more &#8216;accepted&#8217; way to apply formatting to html I discovered that the normal styles like align:center or text-align:center does not work anymore to center an html table horizontally.<\/p>\n<p>Instead to be able to do it you need to add the following css definition:<\/p>\n<blockquote><p>table<br \/>\n{<\/p>\n<p style=\"padding-left: 30px;\">margin-left:auto; margin-right:auto;<\/p>\n<p>}<\/p><\/blockquote>\n<p>That will make it work in Firefox but not IE (9 as tested). To get IE to display it properly you need to enclose the whole table inside another tag &#8211; like a div:<\/p>\n<blockquote><p>&lt;div class=&#8221;centerme&#8221;&gt;<\/p>\n<p style=\"padding-left: 30px;\">&lt;table&gt;<\/p>\n<p style=\"padding-left: 30px;\">&#8230;<\/p>\n<p style=\"padding-left: 30px;\">&lt;\/table&gt;<\/p>\n<p>&lt;\/div&gt;<\/p><\/blockquote>\n<p>plus add css for the div:<\/p>\n<blockquote><p>div.centerme<br \/>\n{<\/p>\n<p style=\"padding-left: 30px;\">margin-left:auto; margin-right:auto;text-align:center;<\/p>\n<p>}<\/p><\/blockquote>\n<p>Not pretty but it works.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Quick tip. Since css is the more &#8216;accepted&#8217; way to apply formatting to html I discovered that the normal styles like align:center or text-align:center does not work anymore to center an html table horizontally. Instead to be able to do &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/hen.co.za\/blog\/2011\/05\/center-an-html-table\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,16],"tags":[9,303,25,24],"class_list":["post-245","post","type-post","status-publish","format-standard","hentry","category-development","category-reference","tag-code","tag-development","tag-html","tag-tip"],"_links":{"self":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts\/245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/comments?post=245"}],"version-history":[{"count":2,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts\/245\/revisions"}],"predecessor-version":[{"id":247,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/posts\/245\/revisions\/247"}],"wp:attachment":[{"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/media?parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/categories?post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hen.co.za\/blog\/wp-json\/wp\/v2\/tags?post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}