Connecting Tech Pros Worldwide Forums | Help | Site Map

Centering two div tags

hgeithus's Avatar
Newbie
 
Join Date: Oct 2008
Posts: 20
#1: Dec 30 '08
Hi.

I have two images with a caption underneath it. (like this example shows: CSS: figures & captions)

So, I want two or more images (with caption) to follow each other on the same line. The question really boils down to this:

How do I center two div tags that are on the same line?

I could do this in my CSS-file:

Expand|Select|Wrap|Line Numbers
  1. div.element {
  2.   float: right;
  3. }
  4.  
Then the two elements would go on the same line, but would not be centered.
I'm kinda looking for something equivalent to this:

Expand|Select|Wrap|Line Numbers
  1. div.element {
  2.   float: center;
  3. }
  4.  
I've heared someone speak of the "display: inline;", but I tried to use it, but it didn't work out very well..

Any help is really much appreciated :)

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,658
#2: Dec 30 '08

re: Centering two div tags


if only the image and the caption needs to be centered use "text-align: center;" If the div should be centered too, use the same on the containing element. If you need something like "float: center" (i.e. text wrapping around a centered image) that's a bit more complicated..... there google will help.

regards
Reply