meyerweb.com

Skip to: site navigation/presentation
Skip to: Thoughts From Eric

Archive: 18 September 2004

Do I Have To Pick One?

Every now and again, I feel good about our city’s main paper, The Plain Dealer.  Today was one of those days; they published a Spinsanity-like piece that dissected the distortions coming from both U.S. presidential candidates.  I was going to lnkblog it, but it turned out they’d split the piece in two on the Web, so I’ll link to them here.

I’d have linked to the printer-friendly versions, except they contained a window.print call, and I wasn’t sure if they’d force a print in some browsers or not.  At the least, they’d call up a print dialog, which is kind of annoying.

The views I expressed in Partied Out are just deepened by this sort of thing.  I know, it’s nothing new.  That doesn’t make it any less depressing.

A Few Spots of Fun

Just in case anyone cares, I’ve finally brought the Media Is Funny and CNN Is Funny pages out of dormancy.  They’re now caught up to this morning.  On a related note, I saw something this morning that didn’t really qualify for either page, but was worth sharing nonetheless.  The ad server at The Weather Channel coughed up a filler image today, and lucky me, I caught it.

A screenshot from weather.com showing a '300 x 600' placeholder in one of the advertisement spots.

So if you were ever curious about how much screen real estate that ad was chewing up… now you know.

Grammar Question

I was just recently asked if attribute selectors must use quotes around the value.  In other words, are both the following two selectors legal?

a[href="http://www.meyerweb.com"] {font-weight: bold;}
a[href=http://www.complexspiral.com] {font-style: italic;}

“No, they’re optional,” I said with assurance.  And then the doubts started to gnaw at me.  What if they actually weren’t, which might make sense given that you can require the exact match of a space-separated list of attribute values? By this, I mean that if you declare:

div[class="this is a test"] {color: orange;}

…then the selector will match any div element whose class attribute is exactly this is a test, in that order, and with nothing else in the attribute value.  Or so I’ve always been given to understand.  In that case, if you left off the quotes, couldn’t that somehow be confusing to the browser?  Maybe not, but it still bothered me.

So I went digging through CSS2.1, Appendix G and found the grammatical definition of an attribute selector.

attrib
  : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S*
    [ IDENT | STRING ] S* ]? ']'
  ;

You all understood that, right?  Uh-huh.  Me either.  (This is one of those hostile-to-outsiders posts I mentioned a while back.)

I never liked grammar in school, and I still don’t, but it is sometimes sadly necessary.  So here goes.  When you run down the definitions of the all-caps words (I think those are tokens) you find that IDENT is an identifier, which is sort of a catch-all bin for things like selectors, property names, values, and such.  Fine.  STRING, on the other hand, is a collection of symbols and other fun stuff, again including the non-ASCII range but not the ASCII range.  But then it includes the entirety of Unicode.  I’m not sure how much sense that makes, but whatever.

So the whole point of this is: if quotes around an IDENT are optional, wouldn’t it have made more sense to say this?

attrib
  : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S*
    [ STRING? IDENT STRING? ] S* ]? ']'
  ;

Or even:

attrib
  : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S*
    [ '"'? IDENT '"'? ] S* ]? ']'
  ;

It’s the [ IDENT | STRING ] from the original definition that has me befuddled.  It seems like it’s saying you can include an IDENT or a STRING but not both, and since IDENT doesn’t include quotes, that implies that you can either drop in an identifier, or a string with quotes.  Why is this a good idea?  Does it mean that any identifier has to be unquoted?  Does it mean that there’s no practical distinction between a STRING and an IDENT in this situation?  Does it mean that quotes prevent the inclusion of anything useful?  Somebody let me know.

September 2004
SMTWTFS
August October
 1234
567891011
12131415161718
19202122232425
2627282930  

Archives

Feeds

Extras