patndoris.com

thoughts and musings - odds and ends
  • patndoris
  • Tao
Blog Name
  • Contact
  • Home

Float Text - Tutorial

by patndoris on Dec.31, 2008,under Code Snippets

For some time I’ve wanted to organize and post some of the HTML, CSS and JavaScript code snippets I’ve found and used. I hope you’ll try the copy and paste in your blog or on your webpage.

Have you ever wanted to include a quote (or image with quote) in your post, but wanted it set off - display it more prominently than just a blank line before and after or a bit of indent? Float is a great way to achieve this. This floating area is a paragraph unto itself. It’s just that in this case, we want the paragraph side by side with other text, instead of one on top of the other.

Follow up:

Now, let’s talk about the difference between margins and padding. Visualize a square (the “special” paragraph). In this case, there is no border displayed around the box, but it’s helpful to imagine one. The margin is the distance from the imaginary border towards the center of the box. Margin is only about what’s inside the box. Think of padding like a protective layer of space outside the box. Padding is like "personal space" it’s the distance between the box border and other text and graphics. In some cases, you can achieve much the same result using margins or padding. However, the distinction is very important. If you use a colored background or border for your area you will need to understand the difference. So for the sake of simplicity, I will include all the options for both margins and padding in this code. You can always set them at 0px if you don’t need to use them.

For this example I want the text to start at the top of the box, or a top margin of 0px, and ends 5px from the bottom margin. Since I’m using float left for this, I don’t need any left hand padding, but I want to give a 20px space between the quote and my other text. Next, think about where the box will float. Is it left? Right? That’s up to you, but it must be stated in the code. Along with the location will be the size. You’ll want to think about how wide you want this separate area to be. In this example I’m using float left and a 200px width.

Finally, consider text as well. To set a quote off, you’ll likely want to use a different color, perhaps even a different font and add a little flair to get attention. In this example I’m using aqua for my color (you can use the name or the hex code). I’m using Comic Sans MS, normal weight, italic, and 16px in size. I’ve also chosen in justify my text, so it extends fully from left to right margin and appears more box-like.

Here’s the example code to copy, paste, experiment & have fun with!

Here’s an example with an image and caption.


this is my logo

Lorem ipsum dolor sit amet et aspernatur quae explicabo architecto ipsam perspiciatis unde magni ipsam ipsam, ratione odit architecto beatae error quia sit ab aspernatur eos sunt veritatis magni magni, quasi ratione voluptas et explicabo doloremque magni sed dolores eaque aspernatur aperiam fugit explicabo perspiciatis perspiciatis, vitae odit iste ipsam architecto ut ipsa quae error explicabo natus fugit voluptatem.

Now go have some fun and try it out!



Bookmark and Share
:float, float text, tutorial
« Knitting or Yoga?
Quick ! Why Not to Buy a USB Wireless Adapter in 3700 Words or Less »
  • You never know what you might find on my site. Take a look for yourself.

    patndoris.com Website

  • September 2010
    Sun Mon Tue Wed Thu Fri Sat
     << <   > >>
          1 2 3 4
    5 6 7 8 9 10 11
    12 13 14 15 16 17 18
    19 20 21 22 23 24 25
    26 27 28 29 30    


    • Recently
    • Archives
    • Categories
    • Latest comments
  • Tag cloud

    adapter aviary bluetooth bookmarking ccleaner cleanup cloud computer computers cooking crafts disorders firewalls flickr frugal games geek gifts google hijackthis hp html im invisible_folders jokes lg linksys malware malwarebytes media movies music musings optimizer panda philipyeoh philosophy phishing photo photos portable protection recipes recovery registry router science? searching security shopping software soulcast spam spyware sun «thumbnail images» tightwad tutorial tv «tv video» updates usb utilities video videos vista vulnerabilities webdesign website websites windows «wireless n» wlm «work virus» xp

  • Search

  • Blogroll

    • Friend Blogs
      • Eagle_Kiwi on Multiply
      • DaveAmenta
      • This is Philip's Blog
  • Archives

    • August 2010 (3)
    • June 2010 (1)
    • May 2010 (2)
    • March 2010 (1)
    • February 2010 (2)
    • January 2010 (3)
    • December 2009 (5)
    • November 2009 (2)
    • October 2009 (5)
    • September 2009 (2)
    • August 2009 (2)
    • July 2009 (7)
    • More...
  • XML Feeds

    • RSS 2.0: Posts
    What is RSS?
  • © 2010 patndoris.com
  • Contents

    • Windows Live Messenger Beta 2 is Awesome
    • Know the coupon policy where you shop (before you go)!
    • Return to Couponing
    • Windows Live Essentials Wave 4 Public Beta Now Available!
    • How to Peel a Hard Boiled Egg–Without Peeling
    • Windows Live Messenger Wave 4 on the Horizon
    • RSS? Old School?
    • Are We Alone?
    • Hard Work Pays Off
    • Daddy, How Was I Born?
    • NatGeo Wallpaper Downloader - Stunning Images
    • Somebody Stole my Random
    • HTML is a finicky little creature
    • Who blocked me?
    • Malwarebytes Real-Time Protection is Worth the $$
    • Will I WHAT?!
    • Can You Help Me Find...
    • Windows 7 Life So Far
    • A Book Worth Reading
    • The Not So Itsy Bitsy Spider
  • FTC Disclosure:

    This blog is a personal blog. For questions about this blog, please contact doris@patndoris.com. This blog accepts forms of cash advertising, sponsorship, paid insertions or other forms of compensation. The compensation received may influence the advertising content, topics or posts made in this blog. That content, advertising space or post may not always be identified as paid or sponsored content. The owner(s) of this blog is not compensated to provide opinion on products, services, websites and various other topics. The views and opinions expressed on this blog are purely the blog owners. If we claim or appear to be experts on a certain topic or product or service area, we will only endorse products or services that we believe, based on our expertise, are worthy of such endorsement. Any product claim, statistic, quote or other representation about a product or service should be verified with the manufacturer or provider. This blog does not contain any content which might present a conflict of interest.
powered by b2evolution free blog software

A b2evolution port by JC John Sese Cuneta.

Theme: pixel and Sweet Icons by famfamfam.

Contact • Powered by b2evolution

Credits: skin makers • blogsoft • webhosts • blog ads