Build Mobile Websites and Apps for Smart Devices : Style over Substance (part 2) - Rows
2. Rows, Rows, Rows
The next part of our app we’re going to look at are the main rows that make up the indexes of Spots and Stars. Once again, the HTML we’re going to use is fairly basic. Here’s the structure for the list of Spots:
listing 7. spots.html (excerpt)
Some points worthy of note:
We’re using another unordered list as the base element for our list of Spots.
This list has two classes that we’ll use to target all the lists that have the same structure: <table-view> and <table-action>. We’re using <table-view> to refer to all such lists, and <table-action> to identify indexes that have a single direct action.
The block element (<h2>) inside our link (<a>) is valid HTML5. In previous versions of HTML and XHTML, block elements weren’t allowed in this context, but HTML5 has no issue with it.
We’re identifying odd and even rows by an additional <even> <class> on the even rows (the absence of the class implies that the row is odd).
The additional metadata for each “Spot”—the distance from the user and the number of sightings—are wrapped in <span> elements with semantic classes to identify them.
To start on the style for this index, we’ll create some generic styles for all the <table-view> elements. These will be used for the indexes of “Spots,” “Stars,” and “Sightings”:
listing 8. stylesheets/screen.css (excerpt)
At the design phase for this element, we mentioned that we need to keep performance in mind for these elements in particular. We’re staying true to that here and keeping the styles as simple as possible—relying on basic CSS like borders to create the illusion of depth without heavy images. This brings us to the point shown in Figure 3; see how the simple dark-to-light borders gives the impression that each row has a slight bezel.
Figure 3. Simple techniques like using dark-to-light borders are effective in creating depth

Now we can flesh out the elements inside each row:
listing 4. stylesheets/screen.css (excerpt)
This code is all stock-standard CSS, but there are some points worth noting:
Our list is really starting to take shape now, as Figure 4 shows.
Figure 4. The elements in our list are now fully styled

This exact same code can be applied to our “Stars” list, as the underlying HTML is almost identical:
listing 10. stars.html (excerpt)
Without making any changes to our CSS files, the “Stars” index will now look like Figure 5.
Figure 5. The same CSS applies to the listing of Stars

Writing modular and reusable CSS is as important as ever on mobile devices. The more generic we can make our CSS, the smaller the stylesheet our users have to download.
Tip:
Validation
Remember to validate! While even the browsers on mobile devices will do their best to deal with malformed HTML, we can make their job (and ours) a whole lot easier by ensuring that our HTML meets the W3C specifications. By ensuring our HTML is well-formed, we increase our cross-platform compatibility and minimize rendering errors. This is especially important going forward—testing against the current crop of browsers is great, but what about the browser that’s released six months from now? A year from now? Code that validates is the most reliable guarantee that future web platforms will handle it as designed.