Web Design Training courses, videos & tutorials at DigitalFamily.com
Web design & Internet trends
books, videos, training & consulting
  • Home
  • Store
    • Web Design Books
    • Dreamweaver Videos
    • Expression Web Videos
    • Products
    • Shopping Cart
    • Order Status
  • Consulting Services
  • Web Tutorials
    • Web Design 101
    • Mobile and Responsive Web Design
    • Social Media
    • Online Reputation
    • Dreamweaver
    • Expression Web
    • Cascading Style Sheets
    • WordPress
  • Dreamweaver
    • CS6 Tutorials
    • CS5 Tutorials
    • CS4 Tutorials
    • CS3 Tutorials
  • FAQ
    • Dreamweaver
    • CSS
    • Graphics
    • WordPress
    • Ask the Author
  • About Us
    • About DigitalFamily.com
    • About Janine Warner
  • Contact
Search the site...
Home» Tutorials » CSS » How to align images with CSS Floats in Dreamweaver

How to align images with CSS Floats in Dreamweaver

Posted by Janine Warner - September 9, 2012 - CSS, Dreamweaver, Graphics, Tutorials
0

If you’ve ever been frustrated by the limitations of V space and H space (that’s vertical and horizontal space for those unfamiliar with HTML), you’re going to love what CSS can do for your images.

As you’ll learn in this tutorial, using CSS to create styles for your images instead enables you to quickly and easily align images to the right or left of a page, and add margin space exactly where you want it to create as much, or as little, space as you want between the image and any text or other elements around it.

I routinely create two image styles for every site I work on, one that aligns an image to the right, with a little margin space on the left, and another that aligns images to the left, with a little margin space on the right. I often include a little margin at the bottom as well, just to make sure that text and other elements don’t bump into the bottom of my pictures.

If you’re still using V space and H space, this tutorial is for you. Thank your designer stars that CSS has given us a little more design control on the Web.

STEP 1 Insert Images

Insert images into your page using Dreamweaver’s standard insert image features. You can choose Insert>Image or click on the image icon in the Common insert bar at the top of the screen. Select the image you want to insert and click OK.

 

STEP 2 Create a New Class Style

Next, you’ll want to create a new style for your images. Choose Text >CSS Styles>New. In the New CSS Rule dialog, select the Class radio button. Class styles are ideal for image styles like this because they can be used as many times as you want on each page and can be applied to images and other elements.

Enter a name for your style in the Name field. For this example, I called the style .image-right. Note that all class styles must begin with a period. If you don’t type one yourself, Dreamweaver will automatically add a period to the beginning of the style name when you create a class style.

If you choose the radio button next to This document only, your style will be saved in the head area of your HTML file. If you choose Define in, you can save your style in an external style sheet. The advantage is that you can attach the same external style sheet to any page in your web site, a more efficient option than recreating styles for every page, and an easy way to make global updates later.

To create a new external style sheet as you create a new style, choose the radio button next to Define in and click OK. In the Save Style Sheet File dialog, enter a name for the external style sheet, and click OK to continue.

STEP 3 Use Floats to Align Images

In the CSS Rule Definition dialog, choose the Box category from the left side. Click on the drop-down arrow next to Float and select Right.

Then set the Margins. First make sure the Same for All check box is not checked. When I align an image to right, I generally like to include 10 pixels of margin on the left, to create a margin between the image and the text that will wrap around the image when it is aligned right. I also like to include 10 pixels of margin on the bottom. Of course, you should set the amount of margin that works best for your design. Click OK to save the new style.

STEP 4 Apply the New Style

To apply the new style, click to select the image you want to align, and then use the Class drop-down list in the Property inspector at the bottom of the page to choose the new style name. In this example, I’m selecting the style I just created called .image-right.  When you apply the style, the image is immediately aligned to the right and 10 pixels of margin space are added to the left and the bottom.

 

STEP 5 Create Additional Image Styles

Next, you’ll want to create a style to align your images to the left. Choose Text >CSS Styles>New. In the New CSS Rule dialog, select the Class radio button and enter a name in the Name field. In this example, I called the style .image-left.

Choose the radio button next to Define in and select the name of an external style sheet from the drop-down list. Alternatively, you can save your style in the document you are working on by choosing This Document Only. Click OK to continue.

STEP 6 Define Box Category Settings

In the CSS Rule Definition dialog, choose the Box category from the left side of the dialog box. Use the drop-down arrow next to Float to choose Left. Then set the Margins. First make sure the Same for All check box is not checked. When I align an image to left, I generally like to include 10 pixels of margin on the right, to create a margin between the image and the text that will wrap around the image when it is aligned left. I also like to include 10 pixels of margin on the bottom. Click OK to save the new style.

STEP 7 Apply the New Style

To apply the new style, click to select the image you want to align, and then use the Class drop-down list in the Property inspector at the bottom of the page to choose the style name. In this case .image-left. When you apply the style, the image is immediately aligned to the right and 10 pixels of margin space are added to the left and the bottom.

You may want to create additional styles for images with varying amounts of margin space for different uses within your design, but I find that these two styles, image-right and an image-left, solve most of my basic image alignment needs. And if you save them in an external style sheet, as I’ve done in this tutorial, you can attach that same style sheet to other pages in your site and use the same styles for all your images.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Share with your friends

Popular books & videos

  • Dreamweaver CS6 Video

    DW-Video-250
    Designing for Multiple Screens with Fluid Grid Layouts
    Discover how to create web designs that look great on large and small screens. From smartphones to tablets to desktops, the new Fluid Grid Layout in version CS6 makes it easier than ever to set up media queries and design websites with HTML5 and CSS3. More Info »
    $49.99$39.99

    View Cart / Checkout
  • Dreamweaver CS5 Part 3: The New Features

    Dreamweaver-CS5-whats-new
    Training Video DVD
    Upgrading to CS5? Get just the training you need when you upgrade. This video covers the hottest new additions to Dreamweaver's toolset with a focus on how to put these great new features to work right away. More Info »
    $24.99

    View Cart / Checkout
  • Dreamweaver CS5 Crash Course

    Dreamweaver CS5 Crash Course Part 1
    Dreamweaver video DVD
    Dip into web design and learn Dreamweaver fast with this engaging video. More Info »
    $24.99

    View Cart / Checkout
  • Dreamweaver CS4 Essentials

    Dreamweaver CS4 Training Video
    Training Video DVD
    Janine's delightful sense of humor (and The Chocolate Game website) make learning web design with Dreamweaver CS4 more fun in this comprehensive 5-hour course. More Info »
    $39.99

    View Cart / Checkout
  • Dreamweaver CS3 Essentials

    Dreamweaver CS3 Training Video
    By Janine Warner Created with TotalTraining Janine’s patience and delightful sense of humor make learning web design with Dreamweaver CS3 fun. Learn everything you need to build websites with Dreamweaver in this comprehensive 8-hour course. You’ll get up to speed fast with the basics of setting up a site and creating your first web pages, More Info »
    $24.99

    View Cart / Checkout
  • CSS Basics: A Refreshing Way to Learn Cascading Style Sheets

    CSS-Basics-DVD
    Training video DVD
    Whether you are completely new to designing with Cascading Style Sheets, or you really want to master the basics of CSS, Janine's crash course will get you up to speed quickly. More Info »
    $24.99

    View Cart / Checkout
  • Creating CSS Layouts: Getting More Advanced with Cascading Style Sheets

    CSS-Advanced-DVD-500
    Training Video DVD
    Dive deep and learn more advanced techniques with Cascading Style Sheets in Part 2 of Janine's CSS training series. More Info »
    $24.99

    View Cart / Checkout
  • Create a Simple Shopping Cart with Google Checkout

    With DIY Ecommerce, if you know how to copy/paste, you’re halfway there to selling your work online. In this course, Janine gives you an overview of some of the most popular options around and teaches you how to turn a profit on your site using Google Checkout. (This video includes instructions for adding Google Checkout to websites and blogs created with Dreamweaver or WordPress.) More Info »
    $24.99

    View Cart / Checkout
  • Adobe Dreamweaver CS5 Part 2: Designing Web Sites

    Dreamweaver CS5 Part 2
    Training Video DVD
    Take your Web design skills to the next level and learn how to use Dreamweaver's templates and CSS to create and update many pages at once. More Info »
    $24.99

    View Cart / Checkout
© 2001 - 2013 All rights reserved. DigitalFamiliy.com was created by Janine Warner | Terms & Conditions of Use | Privacy Policy
  • Home
  • Store
  • Consulting Services
  • Web Tutorials
  • Dreamweaver
  • FAQ
  • About Us
  • Contact