

Surrounding space (ie, less than 100%), otherwise all talk of centring is pointless. For something to be centred, it must be smaller than the The block occupy 100% of the surrounding space. If you don't, the browser will automatically make This effectively puts the DIV block in the centre of Is obliged to give them the same amount of space. When both margins are set to auto, the web browser I set the left and right margins to auto. I first set the width of the container to include enough space for both the picture and the text. You can add the rule to some other tag, such as an empty DIV, like this: If you don't want the extra height that " " adds to your page, Rule to the line break tag (" ") that follows, so that the content below will not attempt toįlow around those elements.

You can use a paragraph,Īn ordered (ie, numbered) list, a DIV block, or anything else that you want.įinally, since I have floated the picture and text, I have added a " clear: both " Note that I just happened to use an unordered list for my text. Really depends on what you are trying to achieve. I prefer to stack the container and text next to each other, but it Since the former will be flushed to the left, and the latter to the right, with unused space between them. However, if the container is very wide, there will be a gap between the image and the text, If the container into which you placed your picture and text is narrow, the result will probably look the same as using It is also possible to use " float: right " to cause the browser to move the list to the right of the picture. (If there isn't, it will put it below that other element.) To solve this, it will place the list to the left of the element that was floated earlier, if As such, when it encounters this new " float: left " for the text, it will find the spaceĪlready taken. Since the image is specified first in the HTML order, the browser will have already, by this time, floated it to the
