Lots of people float an Adsense ad at the upper corner of their content, but how do you put Adsense IN your content without changing the HTML of the article itself? CSS can do that too! Here is an example of how to float ads down inside a long article. You can use it to embed on the left or right (or both!). A wide banner or horizontal link unit an inch or two down works well for me. Now stop reading this and go cure your visitors' ad blindness! <html> <head> <title></title> <style type="text/css"> #vertspacer1, #adsense1 { float:left; clear:left; padding:0px; margin: 0px; } #vertspacer1 { width: 1px; /* Must be at least 1 pixel */ height: 114px; /* How far down to embed the add */ } </style> </head> <body> <div style="width=600px;"> <!-- Containing div of the article --> <div id="vertspacer1"></div> <!-- Float a vertical spacer along the side --> <div id="adsense1"> <!-- Place Adsense code here --> </div> <!-- Long article text here --> </div> </body> </html> HTML:
Wordpress users might want to try this one, open single.php find <div class="storycontent"> add below <div style="float:left;margin-top:0px;margin-right:6px;"> <p> ADS (for example google adsense code) </p> </div> Your google ads float in the top left corner of the article.
Thank you Carlito or this clever css trick! How can you do this same thing for the bottom of the article, if you don't know its length?
I haven't tried it but I believe that's exactly what Carlito's code will do. James, are you talking about having your post wrap around the ad if the ad is at the end? I don't there's a solid way of doing it. Sure you could write some code to "guesstimate" based on font-size, word count, etc., but you can't factor in things like if the user has increased the text size in his browser or if the browser doesn't allow for odd-numbered or decimal sizes (like IE).
Yes, sketch I'm talking about that, look I've applied Carlito's script to the top adsense (randomly located at float left or right, press refresh) : http://www.senserely.com/james-adsense_notifier_sponsorship.php but at the bottom I have another adsense but can't have the text wrapping around it. I guess it is not possible at the moment, I've tried to look for tutorials on float and all examples are always about the top of the content.
Senserely, you can add on another spacer and put another ad unit further down, but there is no way to float from the bottom up with CSS which is what I think you're asking for.
Senserely, my 2 cents, floating banner ads inside content isn't a good idea, as you can see on your own page, it's pushing your text into this tiny column that has 2 or 3 words at the most per line. People always use square-format ads inside content, it looks much nicer.
Sketch I know it isn't perfect and often it is bad, I use a random script to display different sizes of the ad and also left or right, try to refresh you'll see it's never the same set, especially with the one at the bottom, also random. I like to use the computer to have randomness not like printed paper, it's my mistake for a long time, before it was about using ugly random colors, i don't seem to learn or very slowly.
I tried it today, but it'is a blog with very low traffic so I'll see how the sprinkling of readers react to the new look.
I tried it but I have a couple of unexpected effects. 1) If the article includes graphic elements probably the DIV will be set over one of the images. 2) Sometimes, the article content does not wrap properly and part of the last line of text before the ad ends behind the DIV. Do you know if there is any fix?
Here is the way I managed to conjure http://www.docplanet.org/typo3-cms/adsense-ads-within-content-elements/