My Little Corner of the Net

CSS Tricks: .noprint and .noscreen

Cascading style sheets (CSS) make it easy to target web pages to multiple output media. For example, using different CSS rule sets it is possible to design a single web page that looks visually different on screen, on a hand-held device, or when printed.

On way that I’ve extensively used different CSS media types is to provide printer friendly versions of a page. Since real estate on an 8.5″ x 11″ sheet of paper is limited, I like to remove any extraneous content from my pages when somebody prints them–content such as navigation, that has no meaning on the printed page. To do this I often use a “noprint” class definition in my print stylesheets:

.noprint {display: none;}

Then, in my (X)HTML markup I simply set the class attribute of tags I want to exclude from the printed page to no print. (Note that I often take advantage of the seemingly forgotten fact that an element can use multiple classes):


<ul id="navbar" class="nav noprint">
...
</ul>

Easy shmeasy…now when you print the page the navigation links aren’t there. Since the “screen” style sheet doesn’t define a “noprint” class the browser ignores the fact that it is present on some elements and displays those elements according to other rules.

Likewise, I occasionally want to include something on the printed page that isn’t visible on screen. For example, I’ll often use a background image as page header. Since backgrounds generally don’t print, I’ll often include a text and/or a lightweight image title inside the header div that I want to display only when the page is printed. For this, if you can’t guess already, I use a “noscreen” class in my screen-targeted stylesheet.


<div id="header"><span class="title noscreen">This is the site title</span></div>

Unlike the noprint definition, however, there are many reasons why I would like to still have the noscreen elements to be considered part of the page. For example, since background images have no alt text, users of screen readers won't hear the content if I use display:none to hide it, even if it is repeated in the background image. Instead, I use a variation on the Fahrner Image Replacement technique to move the "hidden" content off the edge of the screen. This has the effect of visually hiding the unwanted content while keeping it available in non-visual circumstances:

.noscreen {margin-left: -999em; height: 0; overflow:hidden;}

This shifts the element way off the edge of the screen (the actual value is arbitrary—any negative value should do, -999em is just the value used in an example I once saw somewhere) and forces it to a height of zero so that it won’t effect the layout of other elements. Since the element is still technically visible screen readers and text-based browsers will still acknowledge it.

I could extend this technique to other media, such as hand-held devices, as well, but at this point I rarely target anything except screens and (indirectly) printers. Further, if I was targeting hand-held devices I would probably use some other technique such as browser detection to determine the device and send out an alternate “light” view to save on bandwidth.

I Want some roBlocks

I just read about roBlocks in an editorial email from Dr. Dobb’s Journal. Basically, they’re little magnetic blocks that you stick together and build robots. The blocks are smart enough to know how they are arranged and can automatically provide various functionality based on that arrangement.

There are currently about 21 different blocks available, each serving a specific function. The blocks are categorized as sensors (light, sound, touch, motion, etc.), actuators (lights, sirens, movements), operators (inverse, sum, max, min, etc.), and utility blocks (power, passive, blocker, and comm).

The creators–a professor and PH.D. candidate from Carnegie Mellon University–are hoping to have the blocks in mass production and on the shelves by December. When they become the hot new item at Christmas, remember that you heard about them here first!

For now, though, have fun with the simulator.

Wide-Area WiFi Comes to Rochester

Driving through town earlier today I noticed a new box on one of the traffic lights near my house. The box, mounted on above the road, had three antennae coming out of it. As I continued to drive I noticed these boxes on several traffic lights in the city as well as one on a telephone pole near the intersection of South Clinton and Westfall Roads.

After a bit of research I confirmed my suspicions that these boxes are, in fact, WiFi transceivers. Evidently (though the information is difficult to find), Frontier Telephone, in connection with Monroe County and the City of Rochester has rolled out an urban WiFi network. Information is surprisingly spotty, but according to these maps (all PDFs) [Rochester], [Greece], [Pittsford]) found on News 10 NBC‘s site, the network covers most of downtown and the “trendy” areas of the city (Park/East/Monroe, South Wedge), a chunk of Greece around Long Pond Road roughly stretching from Elmgrove to Mt. Read and from Ridge Road to Latta Road, and in the Monroe/Clover/French Road section of Pittsford as well as the village.

Free access is available downtown, at Pittsford Plaza, The Mall at Greece Ridge, and Ridgemont Plaza, and in much of the Village of Pittsford according to the maps. In other areas users can purchase prepaid access “cards” online for time in 1 hour, 1 day, 7 day, or 30 day blocks of continuous access time for as little as $1 a day. Existing Frontier High-Speed Internet customers can add the Wireless service to their existing service for about $10/month.

Despite the potential impact this project could have, prior to the research I did to write this post I have seen nothing about it other than speculation and long-term guesstimates. Although the news item on the county’s website fails to include a date, the original announcement appears to have been made on February 12th. At that time Channel 10 reported that the system was already functional in Pittsford and Greece and that the Rochester system should be available “within days.” Frontier apparently sunk $3 million into the project so far, and Maggie hopes to continue working with Frontier and the local municipalities to expand the service to include all Monroe County residents. As of this post the Frontier Citywide Wireless Internet site lists the airport as the only access point in New York state.

I’m curious about the service now. How’s the speed and security? If anyone has used it, let me know.

Signing and Background Noise

Why is it that, when I run into someone I know who is deaf while I am at the gym or out walking or whatever, I have to stop my iPod to have a conversation, but I work I can be on the phone having a spoken conversation with one person while having a second one, in sign, at the same time. It seems that the latter should be more difficult given that I have to actively pay attention to two things at once, yet I find the “background noise” of the iPod more distracting.

Polypro Socks

I went camping with Tay House this weekend. In true Boy Scout fashion the weather was sub-par. Saturday morning it rained. The rain stopped, but then it got warm and lots of the snow and ice started to melt. That made everything wet and muddy.

Many scouts’ boots soaked through and we quickly ran out of shopping bags for the scouts to use to keep their socks and feet dry. Surprisingly though my feet never felt wet.

When I finally took my boots off before bed I discovered that my boots had, in fact, become soaked through and my wool socks were quite damp. My feet, however, remained bone dry thanks to the polypropylene socks I was wearing under my wool socks. For years I have relied on polypro socks for this very reason (and others, like reducing friction and thus preventing blisters when hiking) and I am constantly preaching to the scouts what a great investment they are.

Polypros work because the tightly woven fibers do not allow enough space for liquid water to pass through, yet perspiration, which gets turned to water vapor via body heat, passes through without a problem. Since the socks are made of plastic fibers they don’t absorb water and never become saturated. At just a few dollars a pair they are a very economical way to help stay comfortable even when the weather is not the best.

<