Let’s see an … To center an image using text-align: center; you must place the inside of a block-level element such as a div. But most of you would not have succeeded! It can be easily centered by adding the text-align: center; CSS property to the parent element that contains it. The auto value automatically adjusts the left and right margin and horizontally center align the div element's block box. An element is an inline element (display value of inline-block). This is a Wiki pedia user page. Center Align Image Inside Div. The CSS just sizes the div, vertically center aligns the span by setting the div’s line-height equal to its height, and makes the span an inline-block with vertical-align: middle. To center align the single image inside the div element, you have to use the text align property of CSS with the center as its value. To vertically middle align text in a DIV element, we need to use height CSS property of the DIV element and line-height CSS property of the text that needs to be aligned. If you want to keep text aligned center or right for large or small devices specifically as per viewports then use the text-align property as explained below with examples. Which is valid, because the line-height property inherits from the parent element and applies to all elements. Below are the simple examples you can use to center align the single or multiple images inside the div element. This is not an encyclopedia article. Then it sets the line-height back to normal for the span, so its contents will flow naturally inside the block. Here, you can mention a class name for the div element. If you find this page on any site other than Wiki pedia, you are viewing a mirror site.Be aware that the page may be outdated and that the user whom this page is about may have no personal affiliation with any site other than Wiki pedia.The original page is located at The reason is that this property works on table cells and not on a div element with block display. For making text aligned centered in large devices only, use the text-lg-center class. However, this solution will work only when the width of the parent element is more than the containing div element that you want to align. line-height was just simply used on a div in that example. The key to the above method are the CSS rules of the middle div. If we set both these properties to equal value the text will appear vertically middle aligned within the DIV element. Many of you must have tried vertical-align property to vertically align a div.