Media queries 101

Media queries are part of the CSS 3 recommendations that worked beginning with HTML 4 and CSS 2. Lately they have been touted as a solution to designing for mobile devices. The trend has earned the label “responsive web design.” I thought it was time to look at the basics of media queries.

When you use media queries, you can set up style rules that are based on the media environment of the output device. You might have one set of styles for devices using landscape display, and another for devices using portrait display. Or you might write rules specific to the color bit depth of the output device.

The W3C explains,

A media query consists of a media type and zero or more expressions that check for the conditions of particular media features. Among the media features that can be used in media queries are ‘width’, ‘height’, and ‘color’. By using media queries, presentations can be tailored to a specific range of output devices without changing the content itself.

“A media type and zero or more expressions that check for the conditions of particular media features.” What does that look like in practice?

Start with an @media declaration that sets up the device and the conditions you want to meet. One way to do this is to create a specific stylesheet for various conditions and link to it. For example:

<link rel="stylesheet" media="screen and (color)" 
   href="example.css" />

This uses the familiar stylesheet link to set up a media type – screen – and a condition – the screen displays in color – and links to a stylesheet specific to those conditions. The same thing can be accomplished with the @import method of linking to a stylesheet.

@import url(color.css) screen and (color);

A more manageable solution is to link to a single stylesheet, and put @media rules in that one stylesheet. For example,

@media screen and (max-device-width: 480px) {
  .sidebar {
    float: none;
  }
  body {
    background-color: #fff;
  }
}

With @media rules in a stylesheet, the example style rule specifies a media type – screen – and sets up the conditions with terms and values in parenthesis – (max-device-width: 480px). Then, nestled in curly braces {}, one or more selectors and rule declaration blocks are used to create the desired style. The rules inside the enclosing curly braces will be applied only when the conditions are met. Otherwise, they are ignored.

Beyond the basics, you can get more specific and/or complex. You can use commas to set up a number of media types and conditions. There are operators such as and, not, and only that can set up more precise sets of parameters for applying styles.

The media types

  • all
  • handheld
  • projection
  • screen
  • tv
  • tty
  • braille
  • print

The media features

  • width
  • height
  • device-width
  • device-height
  • orientation (portrait or landscape)
  • aspect-ratio (the ratio of the value of the device-width media feature to the value of the device-height media feature)
  • device-aspect-ratio
  • color (bit depth of the device)
  • color-index
  • monochrome
  • resolution
  • scan (for tv)
  • grid (for tty or some phones)

Values

Values can be expressed in pixels, ems, dpi (dots per inch) and dpcm (dots per centimeter)

Further reading

Useful links: HTML5 questions, Smashing newsletter, WP plugins, teens

A few HTML5 questions that need answering is from Christian Heilmann.

Did you know Smashing Magazine has a newsletter? I just learned about it and think it might be pretty good. You might want to check it out, too.

A nice new WordPress plugin from doodlebee, aka @brassblogs, for those of you who set up WordPress sites for others and want to leave them some hints and reminders is Back End Instructions. Here’s some of the description of how it works.

Using WordPress’ default posting capabilities, mixed in with some custom post types and meta fields (and a little sprinkle of magic fairy dust and a lot of prayers), you can easily create and manage instructions for each page of the back-end of your client’s site. Simply create a post, associate the post with a page in the back-end, add in your content, and voilà: a small button appears at the top of the page that expands with jQuery to show a list of “instructables” (post title links) associated with that page.

Are you watching the new series The Chicago Code? This week the leading tip on solving a crime came from a tweeting teen. danah boyd talks about tweeting teens in Tweeting Teens can Handle Public Life with her usual research-based authority.

SXSWi Outgrows Its Space

SXSW Interactive Logo

SXSW Interactive is growing and growing and growing. The recently published schedule for the event reveals that all that success means the conference has outgrown even the huge Austin Convention Center.

The solution is to use 10 nearby venues such as the Hilton, The Courtyard Marriott, The Radisson, several other hotels plus the AT&T Conference Center as extra ‘campuses’ for SXSWi events. Maps to all the locations will be in the conference materials. Most are within a half-mile of the convention center. There will be three shuttle buses to help you move from one location to another.

Similar themed programming is in a specific location, which will make finding your areas of interest easier. For example, the business themed panels and events will be in the Hilton.

The schedule will be searchable by theme (that’s coming soon), which will also help you figure out where to head for the content you want.

Networking your conference

SXSW provides networking tools at SXsocial.  That will help you find and connect with the people you really want to meet while you’re in Austin. I urge you to make full use of the tools they provide.

If you’re a first timer at the conference, check out the SXSW First-Timers Guide. As a multi-year veteran of SXSW, I suggest you prioritize your goals for the conference and focus on accomplishing them. There will be many distractions. My other advice is don’t drink so much you start every day with a hangover. While you’re in Austin, be sure you eat at Chuy’s – best Tex-Mex in the world!

Any Googlegangers in your life?

You’ve searched Google for your own name. I know you have.

Did you find other people with your name? That’s a Googleganger.

Here’s one man’s story about finding his Googlegangers.

Years ago in the early days of the web, I was contacted by another Virginia DeBolt who was also a writer. I never met her in real life. Sometimes when I’m looking for my name I find someone who is deceased who shared that name. Usually a teacher, as I am.

With a Googleganger, you don’t necessarily expect to be related to anyone who shares your name.

I frequently hear from someone whose last name is DeBolt and we compare genealogy to see if we might be related. So far there hasn’t been anyone who connects within the few recent generations I know something about. But it’s not a common name, so there probably is a distant connection somewhere.

The way we find out history and locate relatives is changing rapidly. See Roots Tech: The History of Your Family is in the Future, which describes how Family Search does genealogy. Or perhaps you’ve seen those TV programs called Who Do You Think You Are? that explore celebrity genealogy using high tech tools.

Are you using high tech to find your history? Do you have any Googlegangers?

Guitar Hero Booed off the Stage

guitar hero logo

Guitar Hero has been strumming klunkers for quite a few financial quarters, and the publisher, Activision, has booed it off the stage. As mentioned in Rolling Stone, the game may live on in mobile or social formats, but not in its current form.

According to News Quest Online and The Huffington Post that also means that 500 people who worked on the product are losing their jobs.

Erin Broadley commented in Was the Death of Guitar Hero Inevitable? Slash, Star of Guitar Hero III: Legends of Rock, Answers Here

Our inner 13-year-old boy cried yesterday when news broke via Rolling Stone that video game company Activision was officially pulling the plug on popular music game franchise, Guitar Hero. The game that made plastic kiddie guitars cool and launched millions of virtual rock star dreams was declared dead.

My inner 13-year-old boy is crying too. I spent many an afternoon trying to make it all the way through a song with one of my granddaughters beside me hitting every note on her plastic guitar. Even though I was awful and they were masterful, it was fun. Both my granddaughters grew out of the Guitar Hero stage. Apparently there weren’t enough young people coming up behind them getting hooked on the game, because it started losing money for Activision a couple of years ago.

It isn’t all music genre games, as Activision tried to hint. Terri Hemmert, in Guitar Hero R.I.P. reports that

Harmonix is doing well with the competing Rock Band line. If you have Beatles Rock Band at home, you’re not alone. Big seller. And look for future Rock Band games this year with Johnny Cash and Bob Marley and the Wailers. Doesn’t get much cooler than that.

Laura June says, “At least we still have Rock Band, right?” as well, in Activision kills Guitar Hero division to the consternation of fake musicians everywhere.

How did this happen?

On TechCrunch, Nicholas Deleon had a snarky theory in Guitar Hero Didn’t Die A Natural Death, But Was Killed By Myopic Greed.

And what could possibly be the reason for that, hmm? Maybe releasing sequel after sequels after sequel in such a quick succession that you don’t give gamers any room to breathe? Gotta maximize short-term profits! The future? That’s someone else’s problem.

Eurogamer took a more in-depth look at the failure in Why Guitar Hero Died. A few quotes:

In 2009 Activision released five separate SKUs of Guitar Hero and the brand essentially lost its relevance.

. . . the fact gamers could play new Guitar Hero games with the peripherals they already owned proved to be the killer blow.

. . . music related games are becoming increasingly risky investments . . .

During the same time, the incidence of active gamers who like to play shooter games ‘a lot’ has increased from 40 per cent to 47 per cent, with Call of Duty leading the charge.

In the Huffington Post article, Guitar Hero Over: Iconic Video Games Gets the Ax, the theory of the failure was

These days, guns are more popular than guitars, at least when it comes to video games.

If my video game playing family members are any indication of a social trend, then the shoot-em-up theory is right. My former Guitar Hero fanatic is now shooting everything in sight in endless iterations of Halo, a game that seems to have killing things as its only objective.

Did Guitar Hero pass in and out of your life, only to become a box of plastic guitars and drum sticks in a closet somewhere, or do you still rock out to Barracuda on a frequent basis? Will you miss Guitar Hero?

Cross posted at BlogHer.

Useful links: alt, alt, alt

Five kinds of ‘alt’ text is from userfocus.

HTML5: Techniques for providing useful text alternatives at the W3C is an Editor’s Draft. Even though this is a working draft and may change, it is one of the clearest and best written things I’ve seen at the W3C. The editor on this one is Steve Faulkner from The Paciello Group.

WebAIM: Creating Accessible Images looks at alt text from the point of view of scenarios.

9 reasons why you should go to SXSWi

SXSW Interactive. What’s the big deal? Why should you go?

Here’s the story in pictures. They should explain everything.

1. You can hear great presentations.

InterAct

2. You can meet people from around the world.

between sessions

3. You can hear experts explain how they do what they do.

HTML 5

4. You can chat with everyone and find contacts.

in the hall

5. The keynote speakers are awesome.

Valerie Casey

6. Geeks and tech toys are everywhere.

charge me

7. People like to do what you like to do – be nerdy.

Connecting Education and Industry

8. Some of the panels are really great.

SXSWi Open Source panel

9. AND, there are parties!

Amanda Coolong - Cogaoke Party - SXSWi 2010
Party Photo credit: (CC) Randy Stewart, blog.stewtopia.com.