January 24th, 2008 by Tom
Css Style Code Wrap Text Around Image or Ads
Actually, this is just a basic in Css about floating but many people don’t know how to do it, I always got questions about how to do this thing so I decided to write this tutorial.
The secret of this technique is a float tag , float: left; , if you want you div box align left, float: right; , if you want your div box align right. see a sample code below or download sample files here. Note : you can change attribute name (.ads_left, .ads_right) to your own.
Example

Save this code in your Css style file.
The Css style code
.ads_left {
float: left;
padding: 5px;
margin: 0;
}
.ads_right {
float: right;
padding: 5px;
margin: 0;
}
How to use it.
Insert this code into you content where you want your image or adsense ad to be displayed (you can view an example in my sample file, download here)
<div class="ads_left"> Your image or ad </div> <div class="ads_right"> Your image or ad </div>
Related Posts
- CSS Tutorials For Beginners
- Create CSS Rollover Menu With Sprite Technique (Video tutorial)
- Making Equal Columns Height in Css Div Tag
- Sample CSS3 Code For Creating Cool CSS3 Stuffs – CSS3 Click Chart
- CSS Box Message Collection
- Creating Css Rounded Corners Video Tutorial
- CSS Text Drop Shadows
- 50 Cool CSS Menus, Free Source Codes + Tutorials
- BonBon Button – Beautiful and Nice CSS3 Button
- Beautiful CSS Web Buttons

January 31st, 2008 at 11:50 am
Thanks for the code, I got it too work. I was thinking I could add it to a particular post (in the code view, not the visual view) but WordPress would convert the to and it wouldn’t work correctly. I did get it too work by putting the in the Main Index Template in case anyone else is having similar issues. Or maybe it was just me, but I have it working now so thank you.
January 31st, 2008 at 11:53 am
Looks like my post removed the html for a DIV and Paragraph so the above paragraph my not make total sense. Basically I had to put the DIV in the MAIN INDEX TEMPLATE (or whatever file someone wants using the theme editor, not in the post inself).
February 1st, 2008 at 1:43 pm
All this sounds fine, but the real question should be: how do you place an image in the center of a paragraph and have the text wrap around in on all 4 sides?
Any ideas?
July 22nd, 2008 at 11:32 pm
Thanks for the tutorial. Ok, taking this further, is a way to :-
- make 2 images ( each at left and right ) for the background of website. Eg, image A as background on the left, while image B as background on the right. Both images should load when visitors view the page.
So how do I tweak the code ? Possible ?
- Randomize the background images ! Eg, when visitors first arrive at the site, they will be shown image A+B for the background ( left and right ). If visitor continue to view 2nd page, there will be another set of images ( let’s say A1/B1 ) to be shown.
and so on…eg, if I have 4set of background images ( A1/2/3/4 & B1/2/3/4 ), each set are to be randomized.
Possible ?
Thanks !
September 25th, 2008 at 7:22 am
Hi!
If you use padding this doesn’t work on IE. You have to use margins instead.
Al Pease: I’ve been thinking about that too for a while, and I can’t get a solution yet. But, however, is really necessary that kind of image alignment? I think that if there’s a simple form to do that, we’ll yet have to find a real use for that.
December 10th, 2008 at 8:35 am
What about IE6 ? Doesn’t wrap at all… is there a way around this?
March 19th, 2009 at 1:33 am
[...] Source [...]
April 8th, 2009 at 10:17 am
This works fine with static text and pre-defined tags, but what about trying to print out some dynamic text? Where would the tags go?
May 3rd, 2009 at 12:01 pm
it doesnt work on mine!!help
September 3rd, 2009 at 6:18 pm
Thank you for your tip.I will be thank ful to you for it every time since it increased my earnings.Thanking you agian.
November 18th, 2009 at 11:48 am
this trick similar type like plugins that i use…
even very easy to use this plugins,
you just put your ads, n you can put ads at top, midle, or bottom your content..
but, this great tricks
December 12th, 2009 at 10:56 pm
doesn’t seem to work in latest opera ?