{"id":99,"date":"2017-03-11T04:56:28","date_gmt":"2017-03-11T04:56:28","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=99"},"modified":"2017-10-15T13:45:31","modified_gmt":"2017-10-15T08:15:31","slug":"solved-5-answers-center-image-using-text-align-center","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/solved-5-answers-center-image-using-text-align-center\/","title":{"rendered":"[ Solved \u2013 5 Answers] Center image using text-align center?"},"content":{"rendered":"<p><span class=\"label label-warning\">PROBLEM :<\/span><\/p>\n<p>The problem is the good way to center an image using css ?<\/p>\n<p>Is the property text-align: center;<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">CSS Code<\/span> <\/div> <pre class=\"language-css code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-css code-embed-code\">img {<br\/> text-align: center;<br\/>}<\/code><\/pre> <\/div>\n[ad type=&#8221;banner&#8221;]\n<p><!--?php include(\"https:\/\/www.wikitechy.com\/html\/cad1.php\"); ?--><span class=\"label label-info\">SOLUTION 1 :<\/span><\/p>\n<p>That will not work as the text-align property applies to block containers, not inline elements, and img is an inline element.<\/p>\n<p>Use this instead:<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">CSS Code<\/span> <\/div> <pre class=\"language-css code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-css code-embed-code\">img. Center {<br\/>    display: block;<br\/>    margin: 0 auto;<br\/>}<\/code><\/pre> <\/div>\n<p><span class=\"label label-info\">SOLUTION 2 :<\/span><br \/>\nThis solution doesn&#8217;t always work. if it doesn&#8217;t, try.<\/p>\n<p>we tried the following solution.<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">CSS Code<\/span> <\/div> <pre class=\"language-css code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-css code-embed-code\">img {<br\/>    display: block;<br\/>    margin: 0 auto;<br\/>}<\/code><\/pre> <\/div>\n<p><span class=\"label label-info\">SOLUTION 3 :<\/span><br \/>\nAnother way of doing would be centering an enclosing paragraph.<br \/>\ntext-align center is a good way to center an image, and did not specify that the property had to be a part of the img tag.<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">HTML Code<\/span> <\/div> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;...&quot;\/&gt;&lt;\/p&gt;<\/code><\/pre> <\/div>\n[ad type=&#8221;banner&#8221;]\n<p><span class=\"label label-info\">SOLUTION 4 :<\/span><br \/>\nYou can do the following solution: text-align:<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">HTML Code<\/span> <\/div> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">&lt;center&gt;&lt;img src=&quot;...&quot; \/&gt;&lt;\/center&gt;<\/code><\/pre> <\/div>\n<p><span class=\"label label-info\">SOLUTION 5 :<\/span><br \/>\nHere the solution is simply change parent align.<br \/>\nTry this one on parent properties text-align:center<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[solved &#8211; 5 Answers] CSS &#8211; text-align center &#8211; The problem is the good way to center an image using css ?Is the property text-align: center;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,24],"tags":[1401,83432,83429,83434,83426,517,83418,518,83419,83420,83430,519,515,43,521,1399,83424,520,83427,516,1406,514,83433,83421,83422,83431,83428,83423,83425,513],"class_list":["post-99","post","type-post","status-publish","format-standard","hentry","category-css","category-html","tag-align-center","tag-align-content-center","tag-align-items-center","tag-align-self-center","tag-align-text-center-vertically","tag-bootstrap-center-image","tag-center-an-image-css","tag-center-div-css","tag-center-image-in-div-vertically","tag-center-image-in-div-vertically-and-horizontally","tag-css-align-center","tag-css-center-image-horizontally","tag-css-center-image-in-div","tag-css-center-text-vertically","tag-css-center-vertically","tag-div-align-center","tag-div-style-text-align-center","tag-horizontal-align-css","tag-how-to-align-text","tag-html-center-image-on-page","tag-html-text-align-center","tag-image-center-css","tag-p-align-center","tag-style-text-align-center","tag-table-text-align-center","tag-td-align-center-is-invalid","tag-text-align-center","tag-text-align-center-css","tag-text-align-center-not-working","tag-text-align"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/99","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}