{"id":543,"date":"2012-04-10T06:40:20","date_gmt":"2012-04-10T06:40:20","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=543"},"modified":"2012-04-10T06:40:20","modified_gmt":"2012-04-10T06:40:20","slug":"center-div-css","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/center-div-css\/","title":{"rendered":"Center Div Horizontally Using CSS Example"},"content":{"rendered":"<p>In this article, I am going to show you a very simple way to <strong>center div using css<\/strong>.<!--more--><\/p>\n<h2>How to\u00a0Center div using CSS:<\/h2>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=543\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<p>Before I show you the markup, let&#8217;s quickly look at the output:<\/p>\n<p><a href=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/uploads\/2012\/04\/center_div_css.png\" class=\"broken_link\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-544\" title=\"Center div CSS\" alt=\"Center div CSS\" src=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/uploads\/2012\/04\/center_div_css-300x79.png\" width=\"300\" height=\"79\" \/><\/a><\/p>\n<p><strong>Example: Horizontally Center div using CSS:<\/strong><\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;style type=\"text\/css\"&gt;\n#outer {\nbackground-color: #930;\npadding: 15px;\nwidth: 500px;\nmargin-left: auto;\nmargin-right: auto;\nmargin-top: 50px;\n}\n#inner {\ncolor: #000;\nbackground-color: #FFCFB9;\npadding: 10px;\nwidth: 200px;\nmargin-left: auto;\nmargin-right: auto;\ntext-align: center;\n}\n&lt;\/style&gt;\n\nHTML:\n\n&lt;div id=\"outer\"&gt;\n\n&lt;div id=\"inner\"&gt;\nThis is inner div.\n&lt;\/div&gt;\n\n&lt;\/div&gt;<\/pre>\n<p>Note that for the demo purposes, I have maintained the width of the outer div at 500px. You may remove\/change it as you need.<\/p>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=543\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<h5>That&#8217;s it!<\/h5>\n<p>Do you know of any other ways to <em><strong>Center div CSS<\/strong><\/em>? Feel free to share your thoughts by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, I am going to show you a very simple way to center div using css.<\/p>\n","protected":false},"author":1,"featured_media":276,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[18,6,13],"tags":[51,52],"class_list":["post-543","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css-tips-and-tricks","category-snippets","category-tips-and-tricks","tag-css-snippets","tag-css-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-8L","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=543"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/543\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}