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

XHTML and HTML Essential Training
Illustration by

Reviewing an alternative solution using CSS


From:

XHTML and HTML Essential Training

with Bill Weinman

Video: Reviewing an alternative solution using CSS

In this movie, I'll show you an alternate approach to assembling our image using CSS instead of tables. Many people try to avoid using tables for layout, preferring instead to use CSS. Without getting into which approach is better, they both work just fine. I'll show you here how you can do this same layout using CSS. So here you see the same exercise we had that we did tables. This is a CSS version. You can see that it looks exactly the same as the version that's done with tables.
Expand all | Collapse all
  1. 5m 10s
    1. Welcome
      1m 16s
    2. Using the exercise files
      1m 23s
    3. Choosing a text editor
      2m 31s
  2. 15m 46s
    1. Introducing HTML and XHTML
      2m 53s
    2. Understanding versions of HTML and XHTML
      2m 25s
    3. Exploring a simple XHTML page
      4m 47s
    4. Understanding the structure of an XHTML document
      2m 58s
    5. Understanding document containers
      54s
    6. Creating and using templates
      1m 49s
  3. 42m 4s
    1. Understanding how empty space is formatted in XHTML
      2m 42s
    2. Using paragraph tags
      2m 42s
    3. Aligning paragraphs
      2m 49s
    4. Understanding block-level and inline tags
      1m 24s
    5. Controlling line breaks and spaces
      5m 43s
    6. Formatting text with phrase element tags
      3m 28s
    7. Formatting text with font markup elements
      3m 24s
    8. Adding document structure with headings
      3m 25s
    9. Formatting quotations and quote marks
      2m 19s
    10. Preserving pre-formatted text
      1m 30s
    11. Selecting a typeface
      4m 33s
    12. Selecting a type size
      2m 11s
    13. Using ordered and unordered lists
      5m 54s
  4. 7m 48s
    1. Using inline images
      3m 17s
    2. Flowing text around an image
      2m 4s
    3. Breaking lines around an image
      2m 27s
  5. 22m 34s
    1. Working with hyperlinks
      7m 46s
    2. Using relative URLs
      3m 5s
    3. Specifying a base URL
      2m 4s
    4. Linking within a page using fragments
      4m 28s
    5. Creating image links
      5m 11s
  6. 22m 56s
    1. Introducing tables
      4m 37s
    2. Formatting tables with CSS
      8m 50s
    3. Aligning images with tables
      5m 7s
    4. Reviewing an alternative solution using CSS
      4m 22s
  7. 14m 31s
    1. Introducing frames
      7m 56s
    2. Hiding frame borders
      3m 15s
    3. Creating inline frames using iFrame
      3m 20s
  8. 20m 50s
    1. Introducing forms: part 1
      10m 37s
    2. Introducing forms: part 2
      7m 45s
    3. Using CGI with forms
      2m 28s
  9. 25m 42s
    1. Introducing CSS
      3m 11s
    2. Understanding levels of inheritance
      6m 10s
    3. Learning CSS syntax
      11m 23s
    4. Using units of measure in CSS
      4m 58s
  10. 1h 45m
    1. Comparing table layout and CSS layout
      1m 25s
    2. Exploring the finished web site
      2m 37s
    3. Building a document header
      8m 18s
    4. Placing a banner and a contact button
      8m 13s
    5. Laying out a main menu
      6m 55s
    6. Creating a layout template: main body area
      13m 31s
    7. Creating a layout template: sidebar area
      5m 17s
    8. Creating a layout template: footer content
      4m 46s
    9. Building a main home page: main body content
      11m 24s
    10. Building a main home page: sidebar content
      8m 52s
    11. Creating a page with a menu, graphics, and formatted links
      13m 26s
    12. Creating a page containing an ordered list
      6m 44s
    13. Creating a page containing video
      10m 45s
    14. Touring the finished site
      3m 45s
  11. 53s
    1. Goodbye
      53s

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 ...
XHTML and HTML Essential Training
4h 44m Beginner Jul 28, 2009

Viewers: in countries Watching now:

In XHTML and HTML Essential Training, Bill Weinman helps designers and coders understand XHTML and HTML. In the process, Bill covers document structure, block and inline-level tags, floating images, controlling white space, phrase and font markup, and tables and frames. He even provides a good introduction to CSS. Bill offers step-by-step guidance for building a complete working web site. Exercise files accompany the course.

Topics include:
  • Understanding the structure of an HTML or XHTML document
  • Creating and using templates
  • Controlling white space and line breaks
  • Making effective use of tables and frames
  • Flowing text around an image
  • Formatting tables with CSS
  • Creating web pages that work properly across platforms and devices
  • Reviewing a case study of a complete web site
Subjects:
Developer Web Web Design Web Foundations Programming Languages Web Development
Software:
HTML XHTML
Author:
Bill Weinman

Reviewing an alternative solution using CSS

In this movie, I'll show you an alternate approach to assembling our image using CSS instead of tables. Many people try to avoid using tables for layout, preferring instead to use CSS. Without getting into which approach is better, they both work just fine. I'll show you here how you can do this same layout using CSS. So here you see the same exercise we had that we did tables. This is a CSS version. You can see that it looks exactly the same as the version that's done with tables.

So let's take a look at the code that makes this happen. So this is our CSS version, and here is the tables version. The tables version you're already familiar with if you did the exercise with the tables version in this chapter. And you'll notice that here's the table borders, cell spacing, cell padding, all set to 0, and your table cells-- all very easy to understand. And then here is the CSS version, and here is the style sheet. This is the CSS inside of this block here, and it's very simple; it doesn't take a lot of CSS.

And here, the structure of this actually looks very, very similar. So there are a few things that we should notice about this. Now the biggest challenge in assembling images, and this is true for both the CSS version and tables version, is to ensure that the image doesn't get disassembled when the browser window is too small for the assembled image. Images are in-line elements in HTML so the browser will try to wrap them if it can. Now for the CSS version, there are different ways that you can do it. My solution here was to put the images in vertical columns with one div for each column, and align those columns using float: left in the CSS, and then wrap it all up in an outer div with explicit dimensions, the exact size of the assembled image, and this works really great.

This makes it so that no matter how you size the browser--and here's the CSS version here-- that image does not get broken apart; it doesn't get wrapped. And that of course is also true for the tables version. So here we have something that's working exactly the same. The difference is that it's organized just a little bit differently. In the tables version, we have them organized across because that's the way that table rows work, so 1, 2, 3, 4, 5, 6, 7, 8, 9. That's actually the way that I numbered the images.

For the CSS version, I have got 1, 4, 7, 2, 5, 8 and 3, 6, 9. These are vertical; these are all the ones in the left column; these are all the ones in the middle column; and these are all the ones in the right column. CSS works really well for column layout, and so here instead of laying it out by rows, I laid it out by columns, and that made it work well. In the CSS, for each column--and this is the column layout here--we have a float: left and a margin: 0 and a padding: 0.

So each column will float right up against each other, and they'll actually stack the first one on the left, the second one to the right of that, and the third one to the right of that, and that's how float: left works in CSS. And then there is this outer div, and that one here is cutapartOuter. And that outer div has the exact width and height, and that helps it to know not to break apart. So you'll notice that I used an ID selector for the outer one because I know that there is going to be just one of those in the entire document, so I used an ID selector for that. And for the classes for the individual columns, I used a class selector called cut apart column (cutapartCol), and I used the same class selector for each one of these.

And that allows me to really minimize the amount of CSS that I have here. So it's really not a lot of CSS to make this happen, and it works really well. Now you'll also notice that I put the CSS inside the document. I did that because it makes it easier to describe here in the movie. You can easily put this in an external CSS style sheet. It could be incorporated into something else. It could be incorporated into the rest of your site and it could be organized just as you would with any CSS. So that's how we get exactly these same results using a CSS style sheet for layout instead of using tables for layout as we did in the previous version.

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


Expand all | Collapse all
please wait ...
Q: In this title, the instructor uses tables to create a website design. Is there a way to create this same layout with CSS?
A: This course will be updated to include CSS-based layout techniques within
the next few months. In the meantime, please see Bill's <a href="
http://www.lynda.com/home/DisplayCourse.aspx?lpk2=52341">CSS for
Developers</a> title for more information on coding with CSS.
Q: In the "Understanding the structure of an XHTML document" movie in Chapter 1, where does the "Roses are red," etc, text come from? I don't see it in the code.
A: Notice the <frame src="??"> tags. These reference other .html files that contain the content of the various frames. Details about how frames work can be found in Chapter 6 of the course.
Q: In this title, the instructor uses tables to create a website design. Is there a way to create this same layout with CSS?
A: This course will be updated to include CSS-based layout techniques later in 2012. In the meantime, please see Bill's CSS for Developers title for more information on coding with CSS.
 
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 XHTML and 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

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.