Chapter 10. Case Study: Roma Italia

Annotated and worn, my first-edition copy of this book still sits proudly on my bookshelf. I've referenced it often during the three years since its publication. Much has changed in our industry during this period, most notably the release of Internet Explorer 7 (and later, 8) yielding a bevy of new CSS 2 and CSS 3 features now supported among the major browsers. We'll cover several of these in this case study.

Yet, much has remained the same. Markup is still markup. Standards are still standards. And the need for talented individuals such as yourself who know how to produce beautiful, usable experiences with HTML, CSS, and JavaScript remains not only imperative but even more important, if anything.

Chances are you, the reader, are more knowledgeable and experienced since publication of the first edition. As such, I hope the case study I've crafted will challenge you even more than the previous one. In this case study you will learn about

  • The 1080 layout and grid

  • Advanced CSS2 and CSS3 features

  • Font linking and better web typography

  • Adding interactivity with Ajax and jQuery

View the case study online here: roma.cssmastery.com. The source files are also available from www.friendsofed.com.

About this case study

Roma Italia is a fictitious website created expressly for this case study (Figure 10-1 shows the home page). The CSS techniques employed in this case study, however, are anything but artificial. Each technique was carefully selected with the intent of providing you with a solid selection of advanced CSS techniques, many of which are applicable in real-world environments. Other experimental techniques with less consistent support among current browsers are meant to demonstrate what's coming in the near future.

This case study site, which purports to be a guide to Rome, Italy, consists of two pages: the home page and the video page. Some of the links on the home page link out to real resources, and the rest are dead links only for demonstration purposes. All photography, video, and content for Roma Italia are material from a trip my wife and I recently took to Rome, Italy. For all intents and purposes, this fictitious site could very well be a real site if all of the links actually went somewhere.

Special thanks to Aaron Barker (aaronbarker.net) who assisted with several of the jQuery and AJAX examples in this case study, and my wife Suzanne for some of the photos featured on the site.

Roma Italia home page

Figure 10.1. Roma Italia home page

The foundation

When drafting markup, the factors I consider most important are that it be as meaningful and as lightweight as possible. By meaningful, I mean the HTML elements and selector names we choose appropriately represent the content in such a way that if we were to experience the web with all styling removed, the hierarchy and structure of the content would still make sense. Long gone are the days of spacer GIFs and repeated br elements. These have been replaced with elements that logically, or semantically, represent the content:

  • An ordered list of top-selling items (ol)

  • The principal heading on a page (h1)

  • A quotation from a happy customer (blockquote and cite)

This approach requires that we remove presentational information from our thinking, a concept described comprehensively by Andy Clarke in his remarkable book, Transcending CSS (New Riders, 2006). I still vividly recall my early experiences with CSS as we coded a rather large-scale web application, thinking we were cleverly creating a series of presentational class names that allowed us to mark up content with elegant clarity such as this:

<p class="arial red 10">

only to endure a painful day of reckoning when the application required a redesign, and dozens of templates were to become anything but red Arial 10-pixel type.

By lightweight, I mean marking up our content with the fewest parts possible for all things markup—elements, attributes, and values for HTML; selectors, properties, and values for CSS. For example,

background-color: #c27e28;
background-image: url(../img/feature-orange.jpg);
background-repeat: no-repeat;

is minimized as

background: #c27e28 url(../img/feature-orange.jpg) no-repeat;

You'll see numerous examples of meaningful and lightweight markup throughout this case study, some of which I'll describe here and the large majority of which you'll be able to discover on your own.

An eye toward HTML 5

On the topic of meaningful and lightweight markup, I've chosen to go with HTML 4.01 Strict as the DOCTYPE, favoring it above XHTML 1.0 Strict and HTML 5. I'll briefly explain my reasoning.

XHTML 1.0 Strict: This is what many of us in the industry, including myself, have been using for the past few years. However, Dave Shea offers a compelling argument to drop XHTML with an eye towards HTML 5:

"Six years ago, many of us thought XHTML would be the future of the Web, and we'd be living in an XML world by now. But in the intervening time, it's become fairly apparent to myself and others that XHTML2 really isn't going anywhere, at least not in the realm that we care about. . .I'm not ready to start working through the contortions needed to make my sites work with an HTML5 DOCTYPE yet, which leaves me with the most recent implemented version of the language. . .[U]ntil I get a better sense that HTML5 has arrived, 4.01 will do me just fine for the next four or five years" ("Switched," http://mezzoblue.com/archives/2009/04/20/switched/).

HTML 5: In a nutshell, HTML 5 is the next major version of the hypertext markup language. The good news is meaningless div and span elements will be replaced by more meaningful elements such as nav, header, and video.

This means instead of marking up something such as

<div class="header">
  <h1>Page Title</h1>
</div>

or

<object><param/><embed src="http://vimeo.com/3956190"></embed></object>

we'll be able to mark up the same HTML like this:

<header>
  <h1>Page Title</h1>
</header>

and this:

<video src="http://vimeo.com/3956190">

The bad news is as of the publication of this case study, HTML 5 is not supported adequately by major browsers (notably Internet Explorer). Estimates range from months to years before HTML 5 is fully supported and therefore a viable option for all of us creating websites.

An alternate approach is to maintain that same watchful eye towards HTML 5 by writing markup using current DOCTYPEs but with semantic, HTML 5-like class names. Jon Tan covers this approach beautifully in "Preparing for HTML 5 with Semantic Class Names" (http://jontangerine.com/log/2008/03/preparing-for-html5-with-semantic-class-names).

For example, using the nav element, HTML 5 markup would be

<nav>
  <ul>
    <li><a href="">Menu item 1</a></li>
    ...
  </ul>
</nav>

while our semantic, HTML 5–like markup using HTML 4 or XHTML 1 would be

<div class="nav">
  <ul>
    <li><a href="">Menu item 1</a></li>
    ...
  </ul>
</div>

However, the drawback to this approach is you potentially end up with a lot of extra divs. If our goal is meaningful and lightweight markup, the most optimal markup right now would instead be the following:

<ul class="nav">
  <li><a href="">Menu item 1</a></li>
  ...
</ul>

So, my opinion about HTML 5? We'll all adapt just fine when it's ready for prime-time and fully supported. The mental shift will be minimal. Until then, I'll keep coding the way we've always done it.

For additional resources on the topic of HTML 5, visit the following:

  • 12 Resources for Getting a Jump on HTML 5:

    http://cameronmoll.com/archives/2009/01/12_resources_for_html5/

  • Coding a HTML 5 Layout from Scratch:

    http://smashingmagazine.com/2009/08/04/designing-a-html-5-layout-from-scratch/

  • Wikipedia article on HTML 5: http://en.wikipedia.org/wiki/HTML_5

  • The Rise of HTML 5: http://adactio.com/journal/1540

  • Google Bets Big on HTML 5:

    http://radar.oreilly.com/2009/05/google-bets-big-on-html-5.html

reset.css

When I first began coding CSS-styled sites several years ago, it was common to declare a few "global" styles at the top of the master style sheet: body, a img, h1, h2, h3, and so on. What was done back then as a means of overriding the default styles of any given browser eventually evolved into today's practice of using a "reset" style sheet, typically named reset.css.

As stated by the team at Yahoo, a reset style sheet "removes and neutralizes the inconsistent default styling of HTML elements, creating a level playing field across A-grade browsers. . ." (http://developer.yahoo.com/yui/reset/). I personally prefer Eric Meyer's Reset CSS, which is used in this case study. You can download this style sheet here: http://meyerweb.com/eric/tools/css/reset/.

I use a single style sheet, master.css, to import any number of style sheets for a site. I declare the reset style sheet first, thereby allowing any style sheets that come after to override the reset styles as needed:

@import url("reset.css");
@import url("screen.css");
@import ...

All styles for screen display are listed in screen.css. In the case study site, three additional style sheets are used:

  • autocomplete.css contains styling for the live search feature.

  • datepicker.css contains styling for the calendar date picker.

  • ie.css, which is referenced using conditional comments (see next section), contains styling specific to Internet Explorer.

We could have easily inserted the styles from autocomplete.css and datepicker.css into screen.css, but for the purposes of walking you through this case study, they remain separate.

The 1080 layout and grid

In 2006, I posted a quandary about the optimal width for monitors with a resolution of 1024 × 768 or greater (see http://www.cameronmoll.com/archives/001220.html). It was around this time that many of us who had been developing websites optimized for 800 × 600 for quite some time were beginning to explore widths optimized for a 1024-pixel resolution.

In the same article, I proposed 960 pixels as the ideal width for moving beyond 800 × 600. It accounted for browser chrome as well as for the fact that many users don't browse full-screen. More importantly, 960 is a rather magical number: it's divisible by 2, 3, 4, 5, 6, 8, 10, 12, 15, and 16. Imagine the grid possibilities (we'll get to grids in a minute).

Following publication of the article, 960 nearly became the de facto standard for fixed-width designs on the web. A number of Photoshop, browser, and operating system plug-ins default to it. There's even an entire CSS framework built on a 960 grid, aptly named 960.gs (http://960.gs/). More than three years later, a new question arises: is it time to move beyond 960? I'm uncertain of the answer, but this case study provides the perfect opportunity to explore one.

Before the flak begins flying from fixed-width naysayers, allow me to inform you that I'm a huge fan of fluid designs with min-width and max-width limits, as evidenced by my Extensible CSS series (http://cameronmoll.com/archives/2008/02/the_highly_extensible_css_interface_the_series/) and case study design for the first edition of this book (http://tuscany.cssmastery.com/). In fact, there are some fascinating things we can do with fluid layouts using resources such as Cameron Adams' excellent resolution dependent layout method (http://themaninblue.com/writing/perspective/2006/01/19/) and Ethan Marcotte's fluid images technique (http://unstoppablerobotninja.com/entry/fluid-images/). But I believe there will always be a need for fixed width, and frankly in many ways, it's more practical than fluid width.

So, assuming we agree it's time to at least engage in a discussion about moving beyond 960, what is the ideal width? Here are a few options:

  • 1020 is divisible by 2, 3, 4, 5, 6, 10, 12, 15 but not 8 and 16. It's not much wider than 960.

  • 1040 is divisible by 2, 4, 5, 8, 10, 16 but not 3, 12, or 15. Yet it has a reasonable width that sits somewhere between the lower end of 960 and higher end of users browsing full screen (many don't, as I already mentioned).

  • 1080 is divisible 2, 3, 4, 5, 6, 8, 10, 12, 15 but oddly enough, not 16. It pushes the upper end of the width spectrum, and measure (line length) could become an issue if not dealt with appropriately.

It's worth noting that integer divisions are not the only possibility for grid divisions, or even the most optimal in some cases. Ratio divisions such as the golden ratio (http://en.wikipedia.org/wiki/Golden_ratio) can also be considered. But as Jason Santa Maria points out, ratio divisions may not be practical on the web as they rely on the horizontal and vertical divisions being viewable concurrently, the latter of which often is not (see http://jasonsantamaria.com/articles/whats-golden/).

Conclusively, if we move beyond 960, I'm not certain we'll settle on a clear winner this time around as we did before. None of the widths listed here seem as extensible as 960, at least mathematically. But for this case study, I've chosen 1080. It provides ample options for grids, and it's sufficiently beyond 960 to make the exploration worthwhile.

Using grids in web design

Grids have been in use in graphic design for several decades, but only in the last few years have they really found favor in the minds and voices of web designers—and with good reason at last. Wikipedia offers a succinct description of the grid and its merits, "A typographic grid is a two-dimensional structure made up of a series of intersecting vertical and horizontal axes used to structure content. The grid serves as an armature on which a designer can organize text and images in a rational, easy to absorb manner" (http://en.wikipedia.org/wiki/Grid_(page_layout)).

Grids are comprised of things such as columns, rows, margins, gutters (the space between columns and rows), flow lines (horizontal divisions), and other components. In a medium such as print design, the width and height for each of these components are bound to the finished size of the material; their dimensions are easily calculated by the designer. In web design, however, width dimensions are often much more calculable than height dimensions. This is because of the potentially endless height of a scrollable page.

Accordingly, the armature for the Roma Italia focuses on vertical divisions. Figure 10-2 shows the grid for the site.

The 12-division grid used to design the site

Figure 10.2. The 12-division grid used to design the site

You can toggle this grid on and off by uncommenting the following markup:

<div id="grid"><img src="img/grid.png" alt="" width="1090" height="1380"></div>

This is even easier to do if you have a browser plug-in such as Firebug for Firefox (http://getfirebug.com/) that allows you to temporarily alter a document's markup within the browser. With Firebug open, double-click the body tag to reveal the comment and then edit the HTML right there in Firebug.

Each column is 80 pixels wide with a 10-inch gutter to the right

Figure 10.3. Each column is 80 pixels wide with a 10-inch gutter to the right

As you can see, the grid is divided into 12 columns. Each column is 80 pixels wide with a 10-pixel gutter to the right of each column (as shown in Figure 10-3), which produces a layout 1080-pixel wide. An offset of 10 pixels—essentially an extra gutter—is added to the left margin to balance the grid. However, this offset as well as the gutter alongside the last column to the right are invisible to the viewer. You could argue the grid is actually 1070 pixels wide with these invisible components removed, or conversely, 1090 pixels with the same components made visible. Regardless, our grid is based on an overall measure of 1080.

For the most part, text and images align with columns and gutters. Of course, that's the point of using a grid. Yet you'll notice I haven't aligned every element perfectly. What's important to note here is that a grid doesn't necessarily dictate the exact placement of items. Rather, it facilitates the general positioning of elements, leaving precise positioning to the good judgment of the designer. In Making and Breaking the Grid (Rockport Publishers, 2005), Timothy Samara describes this concept perhaps better than I:

It's important to understand that the grid, although a precise guide, should never subordinate the elements within it. Its job is to provide overall unity without snuffing out the vitality of the composition. In most circumstances, the variety of solutions for laying out a page within a given grid are inexhaustible, but even then it's wise to violate the grid on occasion. A designer shouldn't be afraid of his or her grid, but push against it to test its limits. A really well-planned grid creates endless opportunities for exploration.

But the real power of a grid is found not just in a single page but in the composition as a whole. For example, in a printed brochure, a grid serves to unify the placement of elements throughout the brochure. Similarly, if Roma Italia were a real site, all of its pages—not just the two you see here—would leverage the same grid, yielding visual continuity for the user and limitless layout options for the designer.

I've offered only a cursory discussion of grids in this section. You can find many more resources at The Grid System (http://www.thegridsystem.org/) and in Smashing magazine's "Designing with Grid-Based Approach" (http://www.smashingmagazine.com/2007/04/14/designing-with-grid-based-approach/).

Advanced CSS 2 and CSS 3 features

It wasn't until Internet Explorer 7 was released in October 2006 that instructions like that of this section became both rational and technically feasible. At last IE7 yielded access to many of the exciting features found in the CSS2 and CSS3 specs that had already been supported by Firefox, Safari, and other browsers. Among the most notable were min-width and max-width, attribute selector, adjacent sibling selector, child selector, and alpha-transparency in PNG images.

These well-supported features combined with other features not yet well-supported allows us to do some rather fascinating stuff. An extreme example of this is John Allsopp's recreation of Apple's navigation bar using only CSS, no images (see http://westciv.com/style_master/blog/apples-navigation-bar-using-only-css). Less extreme examples—though I hope still fascinating—are found in this section.

The following advanced CSS2 and CSS3 features are used in Roma Italia:

  • Adjacent selector

  • Attribute selector

  • box-shadow

  • opacity

  • RGBa

  • content

  • Multicolumn

  • text-overflow

  • Multiple backgrounds

  • @font-face

  • min-/max-width, min-/max-height

  • Alpha transparency in PNG images

Of this list, we'll cover the following features throughout this case study: attribute selector, box-shadow, RGBa text-overflow, multicolumn, multiple backgrounds, and @font-face. For those features that are not covered, I've tried to add comments in the markup to assist you in learning on your own time. You may also find it helpful to have this CSS cheat sheet handy in soft copy or printed format: http://cameronmoll.com/articles/widget/cheatsheet.pdf.

Dowebsitesneedtolookexactlythesameineverybrowser.com?

Type this heading into your browser's address bar and you'll discover the answer. This simple site, developed by Dan Cederholm, circled the web in 2008 as virtual propaganda discrediting the myth that websites must look exactly the same in any and all browsers. It was a wake-up call to the web development community to become a little more progressive in its approach to markup, rather than being enslaved by absolute uniformity. In a single word, Dan's site denounced the labeling of visual inconsistency as the red-headed stepchild.

In Roma Italia, the most obvious visual inconsistency deals with the multiple background feature. This feature will allow for several background images per a single element, whereas currently only one image per element is allowed. Rounded corner aficionados rejoice.

As of this writing, Safari is the only major browser to support multiple backgrounds. (Interestingly enough, Safari has supported the feature since version 1.3, dating all the way back to 2005!) This means that in browsers such as Firefox and Internet Explorer, the site will look slightly different. Not only is this intentional for the purpose of this case study, but it's also to demonstrate that it's perfectly legitimate to deliver a slightly different experience to different browsers with no negative effect on the overall user experience.

Multiple backgrounds, which are sure to be a boon to web professionals once fully supported, are easy to style. Simply separate each image and its values with a comma:

background: url(image1.png) no-repeat top left,
  url(image2.png) no-repeat top right,
  url(image3.png) no-repeat bottom left;

Alternatively, properties and values can be defined separately:

background-color: #000;
background-image: url(image1.png), url(image2.png), url(image3.png);
background-repeat: no-repeat;
background-position: top left, top right, bottom left;

Multiple backgrounds are used in our case study site in a couple places, as shown in Figure 10-4. Notice the differences between Safari and Firefox and Internet Explorer.

Differences in the background images between Safari (left) and Firefox and Internet Explorer (right)

Figure 10.4. Differences in the background images between Safari (left) and Firefox and Internet Explorer (right)

Two background images are used in the body to give the site its background texture: the large dark brown image and light brown stripe with a subtle gradient, respectively named bg-dark.jpg and bg-light.jpg. The CSS looks like this:

body {
  background: url(../img/bg-dark.jpg) repeat-x top center,
  url(../img/bg-light.jpg) repeat-x 239px left;
  background-color: #f1efe8;
  }

Because Firefox and Internet Explorer don't yet support multiple backgrounds, and if we leave the CSS as shown, neither image will show up. This will leave the background completely empty, which isn't desirable. So, as a means of at least displaying the dark image, we insert the following duplicate property above the first:

background: #f1efe8 url(../img/bg-dark.jpg) repeat-x;

Firefox reads this property and ignores the other. We repeat the same property in ie.css as Internet Explorer isn't fond of this little hack we've thrown together. The final CSS found in screen.css is as follows:

body {
  background: #f1efe8 url(../img/bg-dark.jpg) repeat-x;
  background: url(../img/bg-dark.jpg) repeat-x top center,
    url(../img/bg-light.jpg) repeat-x 239px left;
  background-color: #f1efe8;
  }

Let's be clear: This isn't the most efficient way to accomplish what we've shown here. First, we could have used a single image that combined the dark and light designs, eliminating the need for multiple background images. Second, we're adding duplicate markup to force Firefox and Internet Explorer to display at least one image. However, the point of these inefficiencies is solely to defend insignificant visual inconsistencies from browser to browser and to demonstrate what's around the corner with multiple backgrounds. For the sake of the collective industry, let's keep our hopes up that the corner is closer than expected.

Attribute selector

The attribute selector eliminates the need to add a class or ID to an element by referencing any attribute or attribute value contained in the element. It can be used on virtually any element with inherent attributes. For example, img[alt] targets an attribute while img[src="small.gif"] targets an attribute value. Further, similar attribute values can be targeted using syntax strings such as img[src^="sm"] which will target any value beginning with the prefix "sm" (e.g., "small"). See "CSS3: Attribute selectors" (http://www.css3.info/preview/attribute-selectors/) for additional examples.

Attribute selectors come in handy in a variety of situations, but probably the most useful is with forms. If elements are styled with a generic hook of input { }, all input elements within the form will be styled. This means that if you're hoping to target text fields only or the submit button only, you're relegated to adding superfluous classes and IDs to do so. The attribute selector, therefore, is a clean way to target specific elements.

This search field uses two input elements, each targeted by an attribute selector

Figure 10.5. This search field uses two input elements, each targeted by an attribute selector

The search field near the top of the site serves as our attribute selector example (see Figure 10-5). The HTML is as follows:

<form action="#" method="get" accept-charset="utf-8">
  <fieldset>
    <legend></legend>
    <label for="search-input">Search</label>
    <input type="text" id="search input" name="search" value="" title="Search">
    <input type="image" name="" src="img/search-go.gif">
  </fieldset>
</form>

Here, we'd like to style the text field with several properties and float search-go.gif to the left. In bold are the two input elements we'll target with an attribute selector. Notice the absence of a class or ID selector within each input element. This is because we can target each using the type attribute, and we do so like this:

#header form input[type="text"] {
  display: block;
  ...
  background: url(../img/search-bg.gif) no-repeat;
  }


#header form input[type="image"] {
  float: left;
  }

Any input element containing the attribute type="image" will be floated left, while any input element containing the attribute type="text" will be styled as we've indicated. Additionally, this same syntax is used in jquery.plugins.js to add jQuery and AJAX functionality:

$('#header form input[type="text"]').searchField();

Both jQuery and AJAX will be treated in a later section.

Box-shadow, RGBa, and text-overflow

In the center of the Roma Italia site, toward the bottom of the page, you'll see a Voices Around the World featurette. If this featurette were real, Twitter updates (tweets) from any users who include the hash tag #romaitalia in their tweet would appear randomly on the map based on the Twitter user's geographical location. Visitors to the site could click these randomized quotes and be taken to page with the full tweet, the author's user name, and tweets from other Roma Italia fans as a means of learning about Rome real-time via Twitter updates. The tweets displayed in the case study are fictitious, but you may follow @roma_italia, a real Twitter account I've set up for this case study.

Map markers that fade in and out with additional text revealed on hover

Figure 10.6. Map markers that fade in and out with additional text revealed on hover

The markers that fade in and out every couple of seconds are rather complex codewise (see Figure 10-6), and we'll use the markup for these to demonstrate the CSS 3 features box-shadow, RGBa, and text-overflow.

Each marker is composed of three parts: the tweet text, a white background with a drop shadow, and a dot image for the map marker. The marker is wrapped in a list item (li), which is housed in an unordered list (ul) containing the world map background image:

<ul>
  <li class="l1" id="map2" style="top: 61px; left: 53px;"><a href="#">
  <em>"Absolutely divine. Don't skip the Il Vittoriano. Its size alone is
  impressive. There's a stunning view from the top."</em></a></li>
  <li>...</li>
</ul>

We style the ul with the following properties:

#voices ul {
  position: relative;
  width: 310px;
  height: 178px;
  background: url(../img/bg-map.gif) no-repeat;
  }

Notice we've set the position to relative. This allows us to absolutely position each list item relative to the ul. Otherwise, the list item would position relative to another parent element, most likely the body. (See Chapter 3 for a refresher on absolute positioning.)

Each map marker li is styled accordingly:

#voices ul li.l1 {
  position: absolute;
  adding-top: 16px;
  background: url(../img/mapmarker-dot.png) no-repeat 2px top;
  }

The map marker dot is embedded as a background image, and the class l1 indicates location number one (dot to the right), while l2 indicates location number two (dot to the left). Absent are the location properties that position each marker on the map. This is because we dynamically position each marker as it fades in using an inline style, which for this particular marker is style="top: 61px; left: 53px;". That is, 61px from the top of the ul and 53px from the left of it.

The white background on which the tweet text rests is slightly transparent and has a drop-shadow on the left, right, and bottom edges. These two styles are accomplished using RGBa and box-shadow, respectively:

#voices ul li.l1 a {
  display: block;
  padding-left: 11px;
  font: 11px/14px Georgia, serif;
  color: #32312a;
  -webkit-box-shadow: 0 2px 3px rgba(0, 0, 0, 0.35);
  -moz-box-shadow: 0 2px 3px rgba(0, 0, 0, 0.35);
  background-color: rgba(255, 255, 255, 0.78);
  }

As box-shadow and RGBa are covered in Simon's case study in Chapter 11, please refer to his text for an explanation of these two features. Note, however, that RGBa opacity differs from another CSS 3 feature called opacity. RGBa opacity can be applied to a specific property, such as background, and it will only affect that property. opacity, on the other, affects everything in the element it modifies, such as this:

#voices ul li.l1 a {
  opacity: 0.35
  ...
  }

The values for opacity are similar to RGBa: 0 (fully transparent) to 1 (full opaque). However, I stress that this affects the entire element. Had we used it here, not only the white background would be 35 percent opaque but the tweet text, too.

When the user mouses over a map marker, the display of the marker changes, as shown in Figure 10-7.

Full text is displayed on hover

Figure 10.7. Full text is displayed on hover

This is where text-overflow comes into play. I wish I had a dollar for every time I could have used this feature in my career—by now, I'd be penning these words from a beach house in the Bahamas. The good news is that today it's fairly well supported across the major browsers. In fact, IE supports it better than Firefox, as does Safari. text-overflow clips a block of text that is too large to fit within its containing element. Using the value ellipsis appends an ellipsis (. . .) to the clipped text.

For each map marker, text-overflow is used to clip the text to one line:

#voices ul li.l1 a em {
  white-space: nowrap;
  width: 135px;
  overflow: hidden;
  text-overflow: ellipsis;
  -o-text-overflow: ellipsis;
  -moz-text-overflow: ellipsis;
  -webkit-text-overflow: ellipsis;
  }

Because this feature isn't officially supported by each browser—even though all of the major browsers do support it—we've added the prefixes -o- (Opera), -moz- (Mozilla), and -webkit- (Webkit). Then, for the mouseover effect, we add the :hover pseudo-class to the element, change the height to 72px, and set overflow to visible.

#voices ul li.l1 a em:hover {
  white-space: normal;
  overflow: visible;
  text-overflow: inherit;
  -o-text-overflow: inherit;
cursor: hand;
  cursor: pointer;
  background: #fff none;
  height: 72px;
  padding-left: 11px;
  padding-bottom: 5px;
  margin-left: −9px;
  }

And that completes the effect—hat tip to CSS3.info for their text-overflow examples, which were inspiration for the creation of this effect. Other CSS 3 features can also be found at their website: http://www.css3.info/.

Font linking and better web typography

We could easily fill the pages of this book with techniques for typography on the web. In the brevity afforded by this case study, we'll cover only a few techniques here:

  • Using px for font-size

  • Hanging punctuation

  • Multicolumn text layout

  • Font linking and embedding

Setting font-size like it's 1999

For a number of years, px was the de facto standard for sizing text with font-size. It gave designers transferring their design from Photoshop (or other software) to HTML a consistent, absolute unit for text size. Then, as we became more knowledgeable of and concerned with accessibility, relative text size (em or %) gradually became the preferred unit. This enabled low-vision users, and really anybody, to change their browser's default text size permanently via the browser's settings or on-the-fly using the keyboard commands Ctrl+ and Ctrl– (Windows) or Command + and Command –.

Accordingly, and up until recently, all major browsers would scale up or down the size of the text while retaining the formatting and layout of the page. This is commonly called text scaling or text zooming. This adaptation required us to create markup that allowed for relative sizing of any elements containing text. For example, if a div contained text set atop a background image, we would have to either repeat the image as the div grew larger with text scaling or create the image larger than necessary to compensate for growth. This is something I covered in detail in my "The Highly Extensible CSS Interface" series of articles (see http://cameronmoll.com/archives/2008/02/the_highly_extensible_css_interface_the_series/).

However, recent versions of every major browser—Safari, Firefox, Google Chrome, Opera, and yes, Internet Explorer—now default to page zooming instead of text scaling for Ctrl +/– and Command +/– commands. Page zooming literally zooms the entire page—layout, formatting, and text size—in unison. Elements retain their size and shape, which greatly reduces the need to compensate for text scaling. In effect, the browser assumes the burden of relative sizing.

What does all this mean? It means px can again be considered a viable value for font-size. It also means the difference between setting text with absolute units or setting text with relative units may be negligible for users. For you and me, however, the difference is significant. The burden of calculating relative units throughout a CSS document is replaced by the convenience of absolute units—14px is 14px anywhere in the document, independent of parent elements whose font-size may differ.

Bear in mind this case study site is meant to be realistic but experimental, as well. I'm at liberty to explore and ask the questions "what if?" and "why not?". Your projects may not yield the same opportunity, so make the right choice for your audience. As with nearly all of the decisions we make as web professionals, you need to make the right decision based on your audience and users. That is the one constant that will never change with all the changes that have occurred and are bound to occur in our industry. In short, if relative sizing is the right choice for your project, no one else can tell you otherwise—including me.

For additional reading on the debate over px for font-size, check out these articles:

  • The Problem with Pixels:

    http://www.wilsonminer.com/posts/2007/mar/16/problem-pixels/

  • IE 7 Does not Resize Text Sized in Pixels:

    http://www.456bereastreet.com/archive/200703/ie_7_does_not_resize_text_sized_in_pixels/

  • Mezzoblue – Zoom: http://mezzoblue.com/archives/2008/10/07/zoom/

  • Hello Old Friend: http://orderedlist.com/articles/hello-old-friend

Hanging punctuation

Hanging punctuation is one of those subtle signals that a skilled typographer is behind the design. These feature is available in most of the Adobe family of design applications, but it's not available as a CSS property. Not yet, that is. There's actually a property called hanging-punctuation proposed in the CSS3 spec (see http://www.w3.org/TR/css3-text/#hanging-punctuation), but to my knowledge no current browser supports this property.

Hanging punctuation aligns punctuation marks outside the text block as to not disrupt the visual flow of the text. Figure 10-8 shows an example using quotation marks.

An example showing how hanging punctuation (bottom) differs from punctuation aligned with the edge of the text (top). The latter is the default in most graphic design software, as well as text within a browser

Figure 10.8. An example showing how hanging punctuation (bottom) differs from punctuation aligned with the edge of the text (top). The latter is the default in most graphic design software, as well as text within a browser

This technique is used in three places on the home page: the first line of text beneath the Roma Moleskine heading (see Figure 10-9), the tweet text in the Voices Around the World map markers, and the orange quotation by the Venerable Bede. The last of these is an image, so we'll cover the first one. The same technique is used for the second.

Hanging punctuation implemented in Roma Italia

Figure 10.9. Hanging punctuation implemented in Roma Italia

The HTML is straightforward:

<div id="featurette1">
  ...
  <p>
  &ldquo;The ultimate traveler&rsquo;s journal.&rdquo; City maps,
  removable sheets, and a 96-page tabbed archive.</p>
  ...
</div>

The HTML entities &ldquo;, &rsquo;, and &rdquo; are curly quotes. These are not necessary for hanging punctuation, but they're yet another subtle signal of good typography. These entities make the source code appear a bit more cluttered to the untrained eye, but the adjusted punctuation rendered by the browser—and noticeable by trained eyes—makes up for the difference.

The CSS is where the magic happens:

#featurette1 p {
  text-indent: -.3em;
  }

And that's it. In your projects, adjust this value depending on the size and family of your typeface.

Multicolumn text layout

With a layout as wide as this one, maintaining a measure (or line length) that is suitable for readability becomes an issue. Measure is the width of a block of text, measured by the number of characters (including spaces) per line. There are countless studies and opinions about the optimal number of characters per line, ranging from 45 to 95 characters per line and varying depending on the medium. This section isn't a discussion about optimal measure, rather one about how to maintain a reasonable measure.

Because this layout is a full 1080 pixels wide, it provides an excellent opportunity to try out the multi-column text feature found in the CSS3 spec. This feature is currently supported by WebKit and Mozilla browsers. Other browsers render the text as a single column as wide as the columns combined.

Robert Bringhurst, in his exceptional and typographically replete The Elements of Typographic Style (Hartley and Marks, 2004), suggests 40–50 characters per line for text set in multiple columns. For the sake of convenience, I've followed his recommendation with this layout.

Shown in Figure 10-10 is a snippet from video.html.

Multicolumn text layout on the video page

Figure 10.10. Multicolumn text layout on the video page

Notice the text is set in two columns. First, the HTML is standard stuff:

<div id="main-video">
  <h3>
  Highlights from a recent vacation to Rome, Italy. Shot with a...</h3>


  <p>I&rsquo;m no video virtuoso. I only dabble with video as time...</p>
  ...
</div>

The CSS, on the other hand, is anything but standard:

#main-video {
  float: left;
  margin: 40px 10px 70px;
  width: 520px;
  -moz-column-count: 2;
  -moz-column-gap: 20px;
  -webkit-column-count: 2;
-webkit-column-gap: 20px;
  }

Here again -moz- (Mozilla) and -webkit- (Webkit) are prefixed out of necessity. Notice there are two properties at play: column-count and column-gap. These properties are fairly easy to understand and to use—set a value for the number of columns you want, and select a value for the gap between them. The entire block of text is then automatically set in the number of columns specified. A third property, column-rule, allows you to add a border between the columns (e.g., column-rule: 1px solid #000;).

Questions about the practicality of multiple-column text on the web and issues with scrolling up and down the page are warranted, but I'm confident that in the hands of a skilled typographer, multicolumn layout has the potential to extend the typography options available to us on the web.

@font-face

The words of Jeffrey Veen, founder of Typekit (http://typekit.com/), are the perfect introduction to this section:

The W3C recommendation for CSS web fonts [@font-face] will be 7 years old soon. Why, after all these years, has typography for the web not progressed further? Why haven't designers embraced linked, downloadable fonts in their designs? (http://blog.typekit.com/2009/06/02/fonts-javascript-and-how-designers-design/)

Excellent questions, Jeffrey. It's highly likely that by the time this book has hit store shelves and worked its way into your hands, Jeffrey's Typekit product will probably have resolved, in a big way, the very questions he's asking. Typekit attempts to resolve the implementation and security issues (discussed later in this section) with @font-face by hosting typefaces centrally that have already been approved by type foundries for font linking (see Figure 10-11).

Typekit offers web font linking without the hassle of @font-face implementation and security issues

Figure 10.11. Typekit offers web font linking without the hassle of @font-face implementation and security issues

Simply put, @font-face provides us with the ability to use virtually any font in our designs rendered as HTML text without worrying about whether or not that font is installed on the user's machine. This is commonly referred to as font linking or font embedding. Instead of this at the top of our document

body {
  font-family: Georgia, serif;
  ...
  }

we can do this

@font-face {
  font-family: "Garamond Premier Pro";
  src: url(fonts/GaramondPremrPro.otf);
  }

Then, we reference the font-family as we're already accustomed to doing:

h1 {
  font-family: "Garamond Premier Pro", serif;
  }

I get giddy just typing all this (geekness, I know). But imagine using any typeface you owned in your site's design and having your text rendered as real, HTML text—no sIFR, no Cufón, no images. You're probably just as giddy now, too.

Of course, if things were that easy, we would have been began using @font-face seven years ago. Indeed, there are caveats. First is—you guessed it—browser support. Safari 3 and newer and Firefox 3.1 and newer support @font-face. So does Internet Explorer 4 and newer. However, IE staunchly supports only the .eot (Embedded OpenType) format, which is essentially a Microsoft proprietary font format. .eot files can be created only from .ttf (TrueType) files, and other font formats such as .otf (OpenType) must be converted to .ttf to then be converted to .eot. No wonder @font-face hasn't taken off.

Second, type foundries and type vendors have been very apprehensive about font linking on the web, and their concern is twofold: because font files are stored on the site and therefore publicly accessible, they may be vulnerable to downloading and illegal use, and because many of their end user license agreements (EULAs) have not been updated to allow for font linking.

However, the good news is also twofold: new technologies are emerging, such as Typekit, that eliminate the two concerns just mentioned, and @font-face encourages the use of typefaces other than the standard set we're all used to (Arial, Georgia, etc.), which inevitably will increase the demand for commercial typefaces. Therefore, type vendors and foundries have a vested interest in seeing font linking and embedding flourish. In fact, during the course of writing this chapter, several foundries have announced new typefaces available for font linking on the Web, and even some have announced significant changes to their EULAs.

Museo Sans, see Figure 10-12, is a typeface by designer Jos Buivenga, released in 2008. In particular, Museo Sans 500 is free, and it's the weight I've used here. Best of all the EULA allows for font linking. (Note that Gotham, the typeface used in the logo and in the titles overlaying the fading feature images, would have been my first choice for font linking. Alas, their EULA didn't allow for it when this site was coded.)

Museo typeface samples. Image courtesy of MyFonts.com

Figure 10.12. Museo typeface samples. Image courtesy of MyFonts.com

In Roma Italia, @font-face is used to demonstrate what is possible now and in the near future. In screen.css, you'll see the following code near the top of the document:

@font-face {
  font-family: "Museo Sans X";
  src: url(../fonts/MuseoSans_500.otf);
  }

Museo Sans is used in several headings and in the top navigation (see Figure 10-13):

#home h3, #home h4, #home #header h2, #home #header ul a {
  font-family: "Museo Sans X", "Lucida Grande", "Lucida Sans Unicode",
    Arial, sans-serif;
  }
Museo Sans is the typeface used in the top navigation

Figure 10.13. Museo Sans is the typeface used in the top navigation

Notice that I've still indicated backup font choices in the event that the user's browser doesn't support @font-face. Also notice that the name of the typeface is Museo Sans X. When you establish @font-face in your CSS, you can name the font-family whatever you want. I could have used Musei Vaticani for all it matters as long as I reference the proper font file (MuseoSans_500.otf). Because Museo Sans is free, you may already have it installed on your machine. I specifically added the X to be sure you're seeing @font-face at work with my copy of Museo Sans and not a local copy on your machine.

Note that I've not converted the Museo Sans .otf file to .eot and therefore Internet Explorer will not recognize it. If you're seeing Museo Sans in Internet Explorer, you're seeing Cufón at work, not @font-face (see the next section).

For additional reading, see the following:

  • Download a copy of Museo Sans at http://myfonts.com/fonts/exljbris/museo-sans/

  • For an extensive review of @font-face and EOT, see Jon Tan's "@font-face in IE: Making Web Fonts Work": http://jontangerine.com/log/2008/10/font-face-in-ie-making-web-fonts-work

Cufón, an interim step toward @font-face

I've posted an extensive tutorial about Cufón on my personal website, which you can find at this address: http://cameronmoll.com/archives/2009/03/cufon_font_embedding/. Because of this, I'll offer only a cursory examination of Cufón in this case study. In short, Cufón allows you to render HTML text in the typeface of your choice without requiring any images or the use of @font-face (see Figure 10-14).

First things first. sIFR, as many of you may be aware, is a means of replacing "short passages of plain browser text with text rendered in your typeface of choice, regardless of whether or not your users have that font installed on their systems" using a combination of Flash and JavaScript (see http://www.mikeindustries.com/blog/sifr/). Shaun Inman, Mark Wubben, Mike Davidson, and several others put in many long hours developing and refining IFR and sIFR, and we all owe them our gratitude for moving forward in a big way the state of typography on the web. What @font-face lacked in browser support and type foundry endorsement over the years, sIFR made up for in the same period.

For many of us, however, the Flash part of these technologies often makes it difficult to set up and use. Cufón, on the other hand, can be set up and run on your site in about 5 minutes. Because of this, I personally see Cufón as an good interim step between sIFR and @font-face should you not have the option of font linking available to you.

Cufón's typeface script generator

Figure 10.14. Cufón's typeface script generator

Here's how Cufón works:

  1. Download the Cufón script file at http://wiki.github.com/sorccu/cufon.

  2. Upload the typeface of your choice using the Cufón generator, which will provide you with a second script file.

  3. In the head of your document, add references to the Cufón script and the typeface script provided by the generator, such as:

    <script src="js/cufon-yui.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/Museo_400.font.js" type="text/javascript" charset="utf-
    8"></script>

    Also add this just before the closing body tag to avoid a flicker issue in IE:

    <script type="text/javascript">Cufon.now();</script>

    Also in the head, indicate which HTML elements or selectors should be replaced with your typeface, such as:

    <script type="text/javascript">
      Cufon.replace('h1'),
    </script>

    or

    <script type="text/javascript">
      Cufon.replace('h1')('h2')('blockquote'),
    </script>
  4. Alternately, if you're using a JavaScript framework such as jQuery on the site where Cufón will be used (Roma Italia includes jQuery), Cufón will take advantage of that framework's selector engine such that you can call out specific selectors like this:

    <script type="text/javascript" charset="utf-8">
      Cufon.replace('#header h2,#header ul a'),
    </script>
  5. In your CSS file(s), modify any text replaced by Cufón the same way you would any other text—color: #333;, font-size: 12px;, text-transform: uppercase;, and so forth.

And that's it. Cufón is currently supported by IE 6, 7, and 8, Firefox 1.5 and above, Safari 3 and above, Opera 9.5 and above, and Google Chrome. In the case study site, I've included Cufón in addition to @font-face, so you can explore the two options. Be aware Cufón shares the same caveat as @font-face when it comes to licensing—the EULA for the typeface you choose must allow for font embedding on the web.

Note that I've wrapped Cufon.replace in a conditional comment because IE won't read the .otf font file we're using for @font-face. Therefore, Cufón becomes a replacement for @font-face in IE for the purposes of this case study. If you'd like to see Cufón work in any browser other than IE, simply remove the conditional comment, and it will override @font-face.

Adding interactivity with AJAX and jQuery

When I first spoke about AJAX in a workshop a few years ago, few raised their hands when asked if they had experience developing sites and applications that employed AJAX. If asked that same question today, it's likely many of you reading this would raise your hands. These questions would probably have similar results if asked about jQuery instead of AJAX.

Indeed, AJAX and jQuery have weaved their way into high-profile sites and weekend projects alike as the de facto twosome for producing rich interactivity on the Web. Of course, the two can be utilized independent of and separate from each other, but it's common to find them used in tandem. Emerging technologies such as Adobe Flex and Microsoft Silverlight challenge the pair's standing as king of the hill, but I suspect we will see AJAX and jQuery remain major players on the Web for at least a few more years.

This section is not meant to be an exhaustive lecture on these two technologies—there are plenty of great books, tutorials, and blog articles already available for that. Instead I offer a brief introduction (or refresher) to AJAX and jQuery and how they are each used in Roma Italia. If you're already familiar with these technologies, skip ahead to "Using AJAX and jQuery for the search feature."

AJAX

AJAX, shorthand for Asynchronous JavaScript and XML, typically includes at least three components:

  • Asynchronous server communication, which is most commonly accomplished via XMLHttpRequest

  • Manipulation of the Document Object Model (DOM) for dynamic display and interaction

  • JavaScript to bind everything together

Asynchronicity is the key component of AJAX—or any rich Internet technology, for that matter—as it provides that native-application feel within the web environment. Instead of the traditional request and response model that fetches an entire page with a full trip to the server, asynchronicity means data is fetched only for a select portion of the page (e.g., user name availability when registering an account).

In Roma Italia, we fake asynchronous server communication for the purposes of demonstration by using a little JavaScript and by fetching data from a few static PHP pages:

  • imageLoad.php for the large feature images that fade in and out

  • search.php for the search field auto-complete feature

Faking asynchronicity merely allows you to download the code samples and open the interface on any machine running PHP, without requiring true server communication.

We'll take a look at the code for auto-complete feature right after the jQuery segment.

jQuery

Karl Swedberg and Jonathan Chaffer's very useful Learning jQuery (Packt Publishing, 2007) describes jQuery as a "general-purpose abstraction layer for common web scripting." I like to think of it as "JavaScript for scripting noobs like me."

jQuery enables you to do the following:

  • Traverse the DOM

  • Modify the appearance of a page

  • Dynamically alter the content of a page

And it allows you to do all this without writing lines and lines of JavaScript. Even better, it leverages CSS syntax for using the selectors in your document as the hooks for creating interaction.

Let's pick apart a sample from another site I've coded to understand the components of jQuery. This is another fictitious site creating for instructional purposes and it can be found at http://cameronmoll.com/articles/widget/.

The Widget demonstration site created for my "The Highly Extensible CSS Interface" series

Figure 10.15. The Widget demonstration site created for my "The Highly Extensible CSS Interface" series

We'll use the Dismiss button located in the yellow notification bar at the top of the page (see Figure 10-15). When clicked, the yellow bar slowly slides upward until it is no longer visible.

Here's the code we add to the button's anchor tag:

$('#alert').slideUp('slow'),

Following is a description of each component:

  • $(): This basic jQuery construct (or function) is used to select parts of the document. In this example, we're selecting an element with the ID of alert.

  • .slideUp: This is one of the many jQuery methods. Methods are essentially a shortcut for lots of JavaScript. It's quite obvious the method slideUp makes the element we're targeting (#alert) slide up.

  • ('slow'): This predefined string establishes how the method functions. In this case, it tells the element to slide up slowly.

This code can be added either inline or in a separate .js file (or dynamically), the latter being the more optimal method. But here's the real kicker: I didn't have to come up with any of this code on my own. The construct, method, and string came prebuilt with jQuery. I just had to know I wanted the element to slide up slowly, and then I looked up the appropriate references in the jQuery library that corresponded with the animation and movement I was seeking. Boom. Done.

Using AJAX and jQuery for the search feature

Now that we've taken care of the instructional housekeeping, let's take a look at an example of AJAX and jQuery working together in Roma Italia. The feature we'll explore is the search feature. Earlier in this case study, we looked at how the attribute selector is used to target specific elements enclosed within the form for the search field. Now, we'll take a look at the other components at play.

The search feature is actually one of the most complex features codewise in the entire site. As a user types a keyword query, the magnifying glass icon is replaced with a loading icon and matching results are displayed. This is sometimes referred to as live search. Both AJAX and jQuery are hard at work bringing this interaction to life. Despite the complexity, piecing the components together is easier than it seems.

First, here's a review of the markup:

<form action="#" method="get" accept-charset="utf-8">
  <fieldset>
    <legend></legend>
    <label for="search-input">Search</label>
    <input type="text" id="search-input" name="search" value="" title="Search">
    <input type="image" name="" src="img/search-go.gif">
  </fieldset>
</form>

To swap in the loading icon, the most lightweight approach I could devise—and one I haven't really seen other sites do yet either—was to combine the background image for the input field and the loading icon into a single animated GIF (see Figure 10-16). CSS is used to position the image based on the state of the interaction, shifting the image up and down as the user types to toggle between the magnifying glass icon and the loading icon.

search-bg.gif, a single animated GIF that includes two states

Figure 10.16. search-bg.gif, a single animated GIF that includes two states

Here's the CSS for the input field:

#header form input[type="text"] {
...
    padding: 6px 0 0 28px;
    height: 20px;
background: url(../img/search-bg.gif) no-repeat;
    }

By default, the background image is positioned at the top left, and we restrict the height to 20 pixels. Add 6 pixels of top padding, and this means only 26 pixels of the image are shown—exactly half the height of the image. Only the magnifying glass portion is revealed.

When the user begins typing, several things happen. First, each time the user types a character, four files are engaged: autocomplete.css, jquery.plugins.js, jquery.autocomplete.js, and search.php. As typing begins, class="ac_input" is dynamically added to the input field and then removed when the live search displays results. This selector is found in autocomplete.css and is styled as follows:

.ac_loading {
background: url(../img/search-bg.gif) no-repeat 0 −26px !important;
    }

Notice the background image is now positioned −26px from the top, shifting the image upward and revealing the lower half (loading icon). This indicates to the user that data is being retrieved asynchronously from the server (search.php).

Second, while the loading icon is spinning, data is exchanged with search.php to locate results matching the characters the user is typing. Open search.php and you'll see some of the terms I've populated the file with—Ancient Ostia, Ancient Rome, Arch of Constantine, and so on.

Third, matching results are delivered back to the page, and a select-like menu is shown beneath the input field with matching results (see Figure 10-17). This menu, which is really just an unordered list (ul), is generated by a combination of jquery.autocomplete.js and jquery.plugins.js and styled by autocomplete.css. The user can then select a match with mouse or keyboard, or continue typing and press the Enter key. This completes the interaction.

The completed search feature in use

Figure 10.17. The completed search feature in use

Now, jquery.autocomplete.js includes several hundred lines of code, but that's another beautiful thing about jQuery—I didn't write any of this. It's a jQuery plug-in written by the community, and many such plug-ins are available. In fact, most of the jQuery in the case study comes from plug-ins. The auto-complete one is jQuery Autocomplete and can be found at http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/.

For additional resources and tutorials, check out the following:

  • Bulletproof Ajax by Jeremy Keith: http://bulletproofajax.com/

  • Ajaxian.com http://ajaxian.com/

  • DHTML Site: Ajax Tutorials and Scripts: http://dhtmlsite.com/ajax.php

  • Official jQuery site: http://jquery.com/

  • Digital Web magazine's jQuery crash course:

    http://www.digital-web.com/articles/jquery_crash_course/

  • Simon Willison's jQuery for JavaScript programmers:

    http://simonwillison.net/2007/Aug/15/jquery/

  • Web Designer Wall's jQuery tutorials for designers:

    http://www.webdesignerwall.com/tutorials/jquery-tutorials-for-designers/

  • Noupe's over 50 amazing jQuery tutorials:

    http://www.noupe.com/jquery/50-amazing-jquery-examples-part1.html

  • 240 plug-ins for jQuery: http://www.sastgroup.com/jquery/240-plugins-jquery

Summary

You've now successfully uncovered many of the techniques used to code Roma Italia. There are plenty more—look under the hood, dive deeper into the code, and you just might find a few more gems.

Take note that the file sizes for this site are rather large, most notably the scripts and feature images. However, if this were a live, deployed site, we'd use actual AJAX to load images individually and we'd minify our scripts. For example, jquery-1.3.2.js is roughly 120KB, but minified and gzipped, it's as little as 19KB. (This compressed version is available for download at jquery.com.) These optimization techniques would dramatically reduce overall page size.

But the real beauty of what's demonstrated in this case study perhaps lies in the fact that the raw HTML markup is just as solid as the aesthetic design. If all styling is disabled, users should have no difficult reading and navigating the site. Though perhaps not beautiful to the web designer's eye, meaningful and lightweight markup is a real treat for screen readers, search engine robots, and the like. It's the best of both worlds—beautiful visual design coupled with elegant source code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.36.174