Lunarpages Internet Solutions Blog
  • Home
  • About Us
  • LunarForums
  • Free Web Tools
  • LunarMods
0

CSS Float Basics

28 December, 2010 - Design, Lunarpages Blog

CSS Image Floating Help

In CSS, the term float usually describes when an element can be pushed to the far left, or the far right, allowing other elements to wrap around it.  Think of it as how you often see things listed in the dictionary.  You have the description to the left, and the image of that thing you are looking up to the right.

Now let us show you how you can get the most out of CSS float.

Elements on a page are usually floated horizontally, (left or right) rather than up or down.  When an element is floated, it will move as far to the left or to the right as it can.  The other elements around it will then be wrapped around it – as you can see in the picture above.

CSS Float Basics

This is the CSS code you would need to make an image float to the right, when placed in front of a block of text:

img
{
float:right;
}

Floating in class or id elements!

You can also define the float tactic when working with a class or id, like so:

.picture
{
float:left;
width:110px;
height:90px;
margin:5px;
}

Stop the Floating!

Elements after the floating element will flow around it. To avoid this, use the clear property:

.text_line
{
clear:both;
}

Try playing around with floating images or boxes of text to the left or right on your own web site layout, and see what you can learn from doing so.  The best way to learn about CSS and designing is to try it yourself.  This floating technique is also often used to make menus hover to the left or right of a web page’s layout, which in turn would eliminate the need for HTML tables.

We hope this comes in handy!

Archives

Categories

View more:

  • About the Lunarpages blog
  • Best Blog Hosting Guide
  • BOTW.org 40% Discount
  • Contact Lunarpages
  • Free Online Tools
  • Free Webmaster Downloads
  • Free Wordpress Themes

Best Web Hosting

Lunarpages.com Web Hosting

Recent Posts

  • Enjoy Backup and File Sync with Sync TOGO
  • JugnooMe: Making Your Business Social Is Our Business
  • An Explanation of HTML5 for Beginners
  • How to Ensure Your Website is Optimized for Top Speed
  • Tips Every Webmaster Should Keep in Mind to Improve On-Page SEO

Recent Comments

  • jocuri kizi on Affiliate Marketing – Part 1 – Why the heck are you not doing this?
  • Kurt on Choosing the Best Ecommerce Shopping Cart
  • Vmelissap123 on Are You Smarter than a 5th Grader?
  • Brennan Scurlock | Review of top 10 web hosting providers. on Site of the Month – Team Brennan
  • iyinet on 10 Best Bookmark and Share WordPress Plugins

@Lunarpages Feed

Who We Are

  • Web Hosting Services
  • About us
  • Partners
  • Affiliate Program
  • Specials
  • 24/7/365 Support Desk
  • Community Forum
  • WIKI

Our Products

  • Colocation Services
  • Fully Managed Services
  • Dedicated Hosting
  • VPS Hosting
  • Microsoft Exchange
  • Open-Xchange
  • Fax To Email
  • Linux Hosting
  • Windows Hosting
  • Reseller Hosting
  • Quicksite Website Builder
  • SEO & SEM Services
  • Payment Processing
  • SecureLive Website Security
  • Tremendesk - Help Desk Solution

Connect With Us

Stay in touch with us!

Sign up for our monthly newsletter to receive updates, news, and current promotions!

Twitter
Facebook Google+ RSS Feed


© 2000 - 2011 Add2Net, Inc. "Lunarpages", "Add2Net" and the "Lunar Symbol" are the trademarks or the Registered trademarks of Add2Net, Inc.
All rights reserved. Unauthorized use is prohibited.