Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center images on a web page for all screen sizes

I'm having a problem with my HTML. I've searched all over the internet, but still no real answer.

I have a website with some images, and I want them to be in the middle. Now, on my screen they're in the middle, but that's because I've put them there by moving them to one side. When my friends to look at it, the image is off-center.

Here's the website; if you are on a 13.5" screen it will look to be in the middle.

like image 942
connor.p Avatar asked May 05 '11 17:05

connor.p


People also ask

How do I center everything on a webpage?

Use a container element and set a specific max-width . A common width many websites use is 960px. To actually center the page, add margin: auto .

How do you center an image on a website?

Step 1: Wrap the image in a div element. Step 2: Set the display property to "flex," which tells the browser that the div is the parent container and the image is a flex item. Step 3: Set the justify-content property to "center." Step 4: Set the width of the image to a fixed length value.

How do I align an image in HTML?

Using Text-align property Another way to align image to the left, centre or right of the page is to use the text-align property. The html code uses the <div> tag and inline CSS style. The following are examples of how to align an image to the left, centre and right. Image will follow the left alignment of text block.


1 Answers

Try something like this...

<div id="wrapper" style="width:100%; text-align:center"> <img id="yourimage"/> </div> 
like image 53
Thomas Shields Avatar answered Oct 02 '22 13:10

Thomas Shields