Computer Science Canada

Changing the display placement of an image

Author:  saltpro15 [ Sat Jan 10, 2009 5:08 pm ]
Post subject:  Changing the display placement of an image

Alright, this is my first html post, as I am brand-new to it, so after about a day of practice (xD) I've only hit one wall for my site. How do I change the placement of an image from the left side of the screen to the centre?

What do I add to this?

HTML:



<img src="whatever.gif">

Author:  syntax_error [ Sat Jan 10, 2009 5:33 pm ]
Post subject:  Re: Changing the display placement of an image

read

Author:  Unforgiven [ Sat Jan 10, 2009 6:09 pm ]
Post subject:  Re: Changing the display placement of an image

syntax_error @ Sat Jan 10, 2009 5:33 pm wrote:


If you meant for him to read about the align property, also read that it's deprecated. If he's asking now, may as well give him the full answer.

To the original poster:

The proper way would be to use CSS. You said you're new, so I won't bother you with details like in-line vs. external style sheets and whatnot, but definitely have a look about that later. For the moment, though, try this to get you started:

code:
<img style="float:right" src="whatever.gif" />


I'm skipping a lot of detail there, though - read up on CSS, and the float property specifically, in more detaile.

Author:  saltpro15 [ Sat Jan 10, 2009 8:42 pm ]
Post subject:  RE:Changing the display placement of an image

ok, i know Turing and C++ but no html so thanks for your help

Author:  jbking [ Mon Jan 12, 2009 2:10 pm ]
Post subject:  Re: Changing the display placement of an image

Another way to go would be to use a div tag around the image so the html would be something like this:

code:

<div style="text-align:center"><img src="Whatever.gif"> </div>


Divs are pretty popular in some circles.

Author:  Unforgiven [ Tue Jan 13, 2009 12:44 pm ]
Post subject:  Re: Changing the display placement of an image

jbking @ Mon Jan 12, 2009 2:10 pm wrote:
Another way to go would be to use a div tag around the image so the html would be something like this:

code:

<div style="text-align:center"><img src="Whatever.gif"> </div>


Divs are pretty popular in some circles.


Yeah, that's perfectly valid as well. Personally, I think it depends on the context - I'd set it to float in the CSS if it were an image to (for example) just be in the same body of content as text (such as an illustration in a long article), and use a div tag with the text-align property if it were a more "standalone" image, something to be treated as a main part of the page by itself.


: