CSS Float


CSS Tutorial  >  Float

One of the commonly-seen layout, especially in large websites displaying ads, is wrapping the text around an advertising block. This is accomplished using the float property.

The float property has three possible values: 'left', 'right', and 'none'. Let's take a look at the following examples:

Example 1: Given the CSS declaration,

#leftfloat {
  float:left;
}

the following HTML,

<span id="leftfloat"><img src="yp.jpg"></span>This example illustrates how float:left affects the appearance of a block. Notice how the image "floats" to the left.

renders,

This example illustrates how float:left affects the appearance of a block. Notice how the image "floats" to the left.

Example 2: Given the CSS declaration,

#rightfloat {
  float:right;
  width:50px;
}

the following HTML,

<span id="rightfloat"><img src="yp.jpg"></span>This example illustrates how float:left affects the appearance of a block. Notice how the image "floats" to the right.

renders,

This example illustrates how float:right affects the appearance of a block. Notice how the image "floats" to the right.

Notice the presence of the width property increases the spacing between the image and the text.

Next: CSS Clear





Copyright 1keydata.com 2007, 2008, All Rights Reserved.   Privacy Policy



CSS Tutorial
CSS Syntax
Apply CSS
CSS Media Types
CSS Cascade
CSS Inheritance
CSS Class ID
CSS Div Span
CSS Length Units

CSS Box Model
CSS Margin
CSS Border
CSS Padding
CSS Background
CSS Color
CSS Font
CSS Link
CSS List
CSS Table
CSS Position
CSS Text
CSS Float
CSS Clear
CSS Cursor

CSS Codes

Resources