www.webdeveloper.com
Results 1 to 5 of 5

Thread: Image Align

  1. #1
    Join Date
    Apr 2006
    Posts
    5

    Image Align

    I am having trouble align an image to "center" or "middle. I have used this code on the page:

    <img src="images/logo.jpg" align="middle">

    This does not work. I even made a new html file with just this code. This image shows up but on the left. What am I missing?

  2. #2
    Join Date
    Nov 2010
    Posts
    15
    To do this try to use the paragraph tag even if you dont use text it will work for you

    <p align="center">

    <img src="images/logo.jpg" />

  3. #3
    Join Date
    May 2005
    Location
    Gold Coast (MS)
    Posts
    2,219
    Maybe...

    CSS:

    Code:
    img#c_enter {
    display: block;
    width: XXpx; 
    height: YYpx; 
    margin: 0 auto;
    border: 0;
    }
    HTML:

    Code:
    <img id="c_enter" src="Path to image" alt="Text Description">
    One way.

  4. #4
    Join Date
    Feb 2008
    Location
    NW Washington State
    Posts
    1,856
    Another option for things like centering images, centering text, or other tasks that you may do over and over in the course of building your site is to create classes for tasks in your style sheet. That way, any time you need to "automate" a task like centering an image, just assign that class to your element.
    Code:
    .center_img {
    	display: block;
        	margin-left: auto;
        	margin-right: auto;
    }
    .center_this {
    	text-align: center;
    }
    .pad_this {
    	padding: 8px;
    }
    As you design more and more sites, you'll find that you can re-use many of those classes again in your new site.... so start a collection of common classes like that, save them into a special CSS file, then you when you start a new site, just copy / paste all those common classes into your new CSS.... saves a lot of work the next time around.
    Best wishes,
    Eye for Video
    www.cidigitalmedia.com

  5. #5
    Join Date
    Nov 2011
    Location
    Indianapolis
    Posts
    9
    Quote Originally Posted by bulbul_2005@hot View Post
    To do this try to use the paragraph tag even if you dont use text it will work for you

    <p align="center">

    <img src="images/logo.jpg" />
    I think this is kind of cheating, but it works.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles