In html, is there a way to center pictures?

  • Thread starter Thread starter Blz
  • Start date Start date
B

Blz

Guest
There are many ways to center an image in HTML. The easiest method is to simply use the <center></center> tag. For example, to center some text you would do the following: <center>This text is centered</center>. If you are looking for a more advanced method you can use CSS, add a Div ID to your image and the following may center an image:
#ImgID {
margin: 0px auto;
}

Hope this helps.
 
I'm taking Webmastering 1 at school, and wanted to show my sister what I could do at home, and I want to try to center a picture under my webpage's title. Is there a way to do this, and if there is, how do I do so?

Thank you in advance!
 
3 Ways:

1) Center Tags:
<center><img alt="" src="" /></center>
-Bad and out dated way

2) Inline Style:
<img style="margin: 0px auto;" alt="" src="" />
-Better then the method above, good for centering 1 image.

3) External Style Sheet:
<img class="imgcenter" alt="" src="" />

Make a style.css file or what ever you want to call it and place this in it:
.imgcenter {
margin: 0px auto;
}
-If you only need to center 1 image this is over kill, but good practice.

Hope that helps,
-FireDart
 
Back
Top