Question:
how do i put an img in the center of any webpage using either html or css?
2008-03-10 07:12:19 UTC
so basically i want this image to be centered at all times no matter what the screen size is right. however the actual code for this image is in some obscure table a long way away from where i actually want the image do be (which is at the absolute center about 100px down from the top). so i simply played with the top and left position values but that only works in 19' wide screen monitors right? on a 15' it wouldnt be in the center.
so how do i make it always centered?



im sure its easy to fix im really tired and cant think
pls help
Three answers:
2008-03-10 07:16:52 UTC
above img source enter the following


and below image source enter


Regards,

G.

http://www.howtoguidehome.com
2008-03-10 07:35:01 UTC
As with most things in using CSS, there are two different things that have to be done to satisfy two different sets of browsers. There is the code to center in modern, standards-compliant browsers, and then there is to code to center in IE.



For modern compliant browsers, step one is to make sure you are using a full and valid doctype at the top of your page. If so, you then apply auto left and right margins to the element you are trying to center. A key component of this, however, is that that element must have an explicit WIDTH. If not, it won't center. This has to do with how box widths are calculated when "auto" values are involved.



That's enough to get things working in FF, Opera, NS, and IE6 (provided you've got that doctype), but it doesn't work in earlier versions of IE, because they don't support auto margins.



For those browsers, you need to take advantage of another shortcoming they have; namely that they erroneously apply the text-align property to block level elements. So if you add text-align:center to the element Containing the thing you want centered (NOT to the centered element, itself), it will center in early IE versions, too.















Sparkles





Play with the values as needed to veritcal center image. Horizontally centering an image is the easy part. Please stay away from using tables for this.
?
2016-12-01 05:45:13 UTC

is technically the paragraph marker. in case you prefer areas in front of words, like indenting, you could variety this: & nbsp ; (without areas) it is a "non breaking area". you will in all danger could desire to apply quite a few to get the size indent you prefer. Use br to place a puzzling end to a paragraph/line. you additionally can use an added br to create an area between paragraphs.



This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...