You may be familiar with the
All cookies aside (but still within reach, of course), when we build vertical expansion of horizontal
Here are some points to remember when you're building horizontal design components:
Chapter 4. Creative Floating
Use floats to achieve grid-like results.
In previous chapters, we started each bulletproof approach by first deciding how the component we're dealing with should be structuredthat is, what markup is most appropriate for the content being displayed? This, I believe, is an important step when building any Web site. With a goal of selecting elements that
Settling on an optimal structure doesn't have to limit the way it's displayed, however. As we'll explore in this chapter, the creative use of the
property can give us grid-like resultswith a
of the code we'd need with the nested-tables approach. By paring down the markup to its barest essentials, we make it easier for browsers, software, and all devices to read our contentat the same time making it easier for other designers and developers to modify and edit these
We start this chapter off by rebuilding a box containing multiple pairings of an image, title, and description. This is a common layout requirement found on sites all over the Web, and one that we can handle elegantly using minimal markup and CSS.
A Common Approach
Often found on sites to display
Figure 4.1. Image, title, and description "packages" like this one are found throughout the Web.
There might also be several of these pairings in a row, each pointing to an article, product, or other destination. Traditionally, one might use a <table> to structure all of this, using spacer GIFs to control white space and gutters in between the items (Figure 4.2).
Figure 4.2. Tables and spacer GIFs may be used to space and position the items.
Some could argue that what we're dealing with here is tabular data (think spreadsheets, calendars, statistics) and I'm not here to debate the use of tables. What we will do is use a particular component from a popular real-world site as a guideline, which we'll then reconstruct using far less markup and CSS to achieve table-esque results. In the end, we'll toss out extraneous markup and unnecessary images to create something more flexible, accessible, and manageable from an editing viewpoint.
Figure 4.3 shows the component from Furniture Shack (a fictitious online merchant of fine home furnishings) that we'll reconstruct. As you can see, it's a bordered box containing three "teasers" to a variety of products available from the Furniture Shack stores.
Figure 4.3. The Furniture Shack home page features a box of "teasers."
Each "teaser" contains a product image, title, and short description. Both the style and layout fit the look of the company's stores and catalogsso, well done there.
Under the hood, this box is built using a series of nested tables and spacer GIFs, and it's worth pointing out that the title text is
WHY IT'S NOT BULLETPROOF
For this particular example, the amount of code required could be reason enough for considering a better approach (Figure 4.4). Reducing the code will not only cut down on file
Figure 4.4. Avoid drowning in a sea of code.
Because of the code bloat, the common approach also scores low in terms of accessibility to a wide range of software and devices. Accessing the rigid construction of nested tables and spacer GIF shims that are used to lay out the design with anything but a standard Web browser could