New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Start learning with our library of video tutorials taught by experts. Get started

HTML Essential Training
Illustration by
Watching:

Flowing text around an image


From:

HTML Essential Training

with Bill Weinman

Video: Flowing text around an image

The HTML image tag is normally an inline element, but sometimes we want to float text around an image. Here is how this is done. Let's start by making a working copy of images.html and I am going to name this images-working.html and open it in my text editor. Here you see just a simple HTML file. It's got an image and it's got some paragraphs with some Lorem Ipsum in them, and if we open this in a browser, you will see that it looks like that. The image is standing by itself, but that's not because it's a block level element. It's not.
Expand all | Collapse all
  1. 5m 24s
    1. Welcome
      56s
    2. Using the exercise files
      1m 37s
    3. What you need to know about this course
      2m 51s
  2. 22m 0s
    1. What is HTML?
      4m 12s
    2. Examining the structure of an HTML document
      7m 50s
    3. Understanding tags and containers
      6m 4s
    4. Exploring content models in HTML5
      2m 23s
    5. Looking at obsolete elements
      1m 31s
  3. 27m 19s
    1. Understanding whitespace and comments
      3m 53s
    2. Displaying text with paragraphs
      3m 37s
    3. Applying style
      8m 5s
    4. Using block and inline tags
      6m 34s
    5. Displaying characters with references
      5m 10s
  4. 16m 36s
    1. Exploring the front matter of HTML
      2m 9s
    2. Applying CSS to your document
      3m 59s
    3. Adding scripting elements
      4m 54s
    4. Using the meta tag
      3m 34s
    5. Optimizing your page for search engines
      2m 0s
  5. 24m 59s
    1. Controlling line breaks and spaces
      2m 46s
    2. Exploring phrase elements
      1m 44s
    3. Using font markup elements
      1m 5s
    4. Highlighting text with mark
      1m 29s
    5. Adding headings
      1m 38s
    6. Using quotations and quote marks
      3m 2s
    7. Exploring preformatted text
      1m 45s
    8. Formatting lists
      2m 28s
    9. Forcing text direction
      3m 49s
    10. Suggesting word-break opportunities
      2m 29s
    11. Annotating East Asian languages
      2m 44s
  6. 29m 15s
    1. Introducing CSS
      55s
    2. Understanding CSS placement
      6m 55s
    3. Exploring CSS syntax
      10m 34s
    4. Understanding CSS units of measure
      3m 3s
    5. Some CSS examples
      7m 48s
  7. 22m 5s
    1. Using images
      4m 13s
    2. Flowing text around an image
      4m 55s
    3. Breaking lines around an image
      3m 3s
    4. Aligning images
      5m 25s
    5. Mapping links in an image
      4m 29s
  8. 22m 28s
    1. Understanding URLs
      2m 41s
    2. Working with hyperlinks
      3m 28s
    3. Using relative URLs
      4m 20s
    4. Specifying a base URL
      2m 19s
    5. Linking within a page
      4m 12s
    6. Using image links
      5m 28s
  9. 17m 2s
    1. Exploring list types
      3m 52s
    2. List elements in depth
      7m 44s
    3. Using text menus with unordered lists
      5m 26s
  10. 15m 30s
    1. Introduction to HTML semantics
      4m 9s
    2. Exploring an example
      4m 56s
    3. Marking up figures and illustrations
      2m 33s
    4. Creating collapsible details
      3m 52s
  11. 11m 18s
    1. Embedding audio
      5m 19s
    2. Embedding video
      5m 59s
  12. 11m 53s
    1. Creating ad-hoc Document Object Model (DOM) data with the data-* attribute
      4m 53s
    2. Displaying relative values with meter
      2m 57s
    3. Creating dynamic progress indicators
      4m 3s
  13. 4m 49s
    1. Overview of HTML5 microdata
      1m 8s
    2. Exploring an example with microdata
      3m 41s
  14. 7m 3s
    1. Understanding outlines
      52s
    2. A demonstration of outlining
      6m 11s
  15. 13m 1s
    1. Table basics
      7m 29s
    2. Exploring the semantic parts of a table
      2m 32s
    3. Grouping columns
      3m 0s
  16. 9m 55s
    1. Frames overview
      54s
    2. Using traditional frames
      4m 26s
    3. Exploring inline frames using iframe
      2m 7s
    4. Simulating frames with CSS
      2m 28s
  17. 53m 7s
    1. Introducing forms
      10m 24s
    2. Using text elements
      10m 12s
    3. Using checkboxes and radio buttons
      2m 37s
    4. Creating selection lists and dropdown lists
      5m 14s
    5. Submit and button elements
      8m 48s
    6. Using an image as a submit button
      2m 15s
    7. Keeping context with the hidden element
      3m 0s
    8. Setting tab order
      2m 7s
    9. Preloading an autocomplete list using the datalist feature
      5m 26s
    10. Displaying results with output
      3m 4s
  18. 19m 47s
    1. Touring a complete site
      2m 14s
    2. Touring the HTML
      8m 44s
    3. Touring the CSS
      8m 49s
  19. 29s
    1. Goodbye
      29s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
HTML Essential Training
5h 34m Beginner Sep 11, 2012

Viewers: in countries Watching now:

This course introduces web designers to the nuts and bolts of HTML (HyperText Markup Language), the programming language used to create web pages. Author Bill Weinman explains what HTML is, how it's structured, and presents the major tags and features of the language. Discover how to format text and lists, add images and flow text around them, link to other pages and sites, embed audio and video, and create HTML forms. Additional tutorials cover the new elements in HTML5, the latest version of HTML, and prepare you to start working with Cascading Style Sheets (CSS).

Topics include:
  • What is HTML?
  • Using HTML tags and containers
  • Understanding block vs. inline tags
  • Controlling line breaks and spaces in text
  • Aligning images
  • Linking within a page
  • Using relative links
  • Working with tables
  • Creating progress indicators with HTML5
  • Adding buttons and check boxes to forms
  • Applying CSS
  • Optimizing your pages for search engines
  • Building document outlines
Subjects:
Developer Web Web Foundations Web Development
Software:
HTML
Author:
Bill Weinman

Flowing text around an image

The HTML image tag is normally an inline element, but sometimes we want to float text around an image. Here is how this is done. Let's start by making a working copy of images.html and I am going to name this images-working.html and open it in my text editor. Here you see just a simple HTML file. It's got an image and it's got some paragraphs with some Lorem Ipsum in them, and if we open this in a browser, you will see that it looks like that. The image is standing by itself, but that's not because it's a block level element. It's not.

It's an inline level element, but it just doesn't have any text around it. It's here separate from the text in the paragraph. So the paragraph actually begins after it which is why it displays the way that it does on the screen. Now if I want this text to flow around the image, there is a couple of different ways that I can do this. In old HTML4 and earlier this was done with an align attribute. I would say align="left" like that, and I could put this back on the line there if I like, but of course HTML ignores all of that whitespace that doesn't actually matter.

And if I save this and reload in the browser, you'll see that now the text flows around the image. There is no margin between them. It's not very attractive, but this is how it used to be done and there are other attributes to put some space between them, and it was all a little bit cumbersome and didn't work very well. Now this still works and you're certainly allowed to do it this way. All the modern browsers support legacy code, but there is a correct way to do it, and technically in HTML5, the align attribute is obsolete and instead we will use a stylesheet.

So I am just going to put a style right here in the HTML for this tag and I am going to say float: left, like that. When I save that and reload it in the browser, you see it accomplishes exactly the same thing. And if I like, I can say float: right, and reload, and now it floats off to the right. But because the paragraph is flushed left, I am going to leave it on the left so that we can see this ugly border right here, and we can see that that's not working very well. I am going to show you what we can do with this. Again using CSS, this becomes very easy.

I can say margin-right: 10px and I can say margin-bottom: 5px, and when we load this up in the browser, we see now we have a nice little margin around the image. I can even put a little border around it. I can say border: solid black 1px, and give it a padding of 2 pixels so there is a little space between the border and the image, and when I reload it, now we have a rather attractive looking image with a nice little border around it and a good amount of margin around it as well.

So you can easily do a lot of things to make this image look good. It's worth noting that any time you add a float, either with the align attribute or with the float property in CSS, that the image actually converts to being a block level element. So now it is block level. It is no longer inline. Of course this is a lot of stuff to type and if you are going to type this much, you are going to want to be able to reuse it, so I am going to go ahead and copy this and I am going to come up here and I am going to create a style, and I am going to call this style float-img.

I am going to put a dot in front of it to make it a class and I'll take all that stuff that I copied and I am just going to--and now we have a nice class for this float image and I can come down here and I can take all of this and I can just say class="float-img" like that, and confirm that that's what I named it and save this and reload it in the browser, and you see that it looks exactly the same. Now if I want to, I can make it float right, and there it is, and if I want to, I can come down here and I can take all of this and I can copy it, and have another image, say this one will be paper, picture of paper, and I can say "Running with this is recommended", and we come over here and load it in the browser.

Well notice it's not quite exactly right. We now have two of them and one of them is to the left of it and the wrapping around isn't right. That's because they're both floating right, and the way to fix this and we are going to talk about this a little bit more later, but we can say clear: right and then each one of these floats will start on a line by itself, and so now it's doing exactly what it is that we meant for it to do, and I can change this margin-right to margin-left so that that looks better, and now it's floating right and it's got a nice little margin next to it.

So you can see that formatting images for display with CSS is easy and powerful. For more foregrounding options, see my CSS for Developers course here on the lynda.com online training library.

Find answers to the most frequently asked questions about HTML Essential Training.


Expand all | Collapse all
please wait ...
Q: The horizontal nab bar built in Chapter 8 doesn't work correctly in Internet Explorer 8. Do you have a solution?
A: Internet Explorer 8 does not support HTML5 and the NAV element.

The nab bar can work in IE 8 if you change the nav element to div, and update the CSS accordingly. You will also need to move the "display: inline" from the "ul.menu li a" rule to the "ul.menu li" rule.
 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

join now Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed HTML Essential Training.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Notes cannot be added for locked videos.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.