IE7 Beta 2

For:

  • Font ren­der­ing. This is how ClearType should have worked years ago.
  • Improved stan­dards com­pli­ance. The Sun­rise Fam­ily site (live) now works with IE7 near-perfectly (i.e. no more or less bro­ken than most other browsers. On par with Fire­fox, worse than Opera and Safari.) Happy happy happy!
  • Zoom. Note this is SEPARATE to font siz­ing. But it’s still a lit­tle broken.
  • Home­page tab group isn’t an exten­sion or extra soft­ware that needs to be added. When­ever you add a home­page, IE prompts you if you want to make this your ACTUAL home­page or add it to the open­ing group of tabs. Play­ing catch-up, sure, but a good fea­ture nonetheless

Against:

  • Font ren­der­ing. It’d be great if it could intel­li­gently antialias only san-serif fonts, and not process fixed-width or ser­ifed fonts, which it invari­ably makes “fuzzy” rather than clearer. Also, font ren­der­ing seems to be smaller by default, which is both a good thing — it’ll force design­ers to make their base font sizes big­ger — and a bad thing — in that, obvi­ously, those design­ers that don’t con­form will be sub­ject­ing users to painfully small text :-(
  • Inter­face. Kudos for think­ing out­side the square, or what­ever, but I reckon peo­ple are going to strug­gle get­ting used to this. I know I will, but that’s prob­a­bly because I switch between at least five dif­fer­ent browsers daily and expect them to all behave about the same. I get con­fused when going between Mac and PC, mostly, because the key­board short­cut bind­ings change from Apple/Start — I’m using a KVM — and con­trol + [key] change, so Inter­net Explorer mov­ing any­thing around is bad for me, unless every­one else fol­lows suit.
  • Bro­ken zoom resizes images + ele­ments in HTML fine, but on one of my sites strug­gles resiz­ing the back­ground on the body (or maybe html?) ele­ment. Also, it doesn’t keep (all) cen­tered sites cen­tered once you zoom. This will obvi­ously have to be fixed for the final release, too. I searched their news­group and couldn’t find any­thing so I posted some­thing about it quickly. Vote for it, please :-)
# by Josh on February 1st, 2006 Tags: , , , ,
| 1 Comment »

Sunrise Family website

A screen capture of the Sunrise Family website

The site

This is the vaguely alluded to web­site of a few days ago, for Seven Network’s break­fast show (I refuse to describe any such com­mer­cial net­work dri­vel as “cur­rent affairs”!), Sun­rise. The Sun­rise Fam­ily is essen­tially an incentive/loyalty scheme vaguely akin to Triple M’s (recently-abandoned… doubt­less to be re-released in nearly exactly the same form under a dif­fer­ent brand) Freq Club and Enter­tain­ment Book–style dis­counts. There might be more later on, but that seems to be about it so far as what’s there right now. And, truth be told, I’m not really sure what else is com­ing… I’d love to replace Sunrise’s bor­ing ROSwall form with some­thing akin to the infa­mous Flash Just Let­ters inter­ac­tive fridge thingo, though maybe in an add-only type way, which would link in to view­ers’ exist­ing Fam­ily login (i.e. so they don’t have to enter their name every time, etc.), but that’s just an idea of mine.

The tech­nol­ogy

So, the deals.

The inter­face is using AJAX, presently with inline onClick trig­gers — because, unfor­tu­nately, I’m not quite good enough to make it pull the data from the ID… though, if you view source, I’ve setup the ID’s to have two pieces of data in there. If any­one can tell me how to write an event han­dler that con­verts an ID into a string which I can then feed to an onClick han­dler (and, server-side, explode() using PHP) I’m still very keen to fix that “prop­erly”. The ID’s have two data ele­ments because the Deals inter­face is designed to add sup­port for mul­ti­ple states (i.e. localised offers, etc.) in the future. And they’re pre­fixed by d_ because, obvi­ously, valid iden­ti­fiers can’t start with a num­ber. D can stand for “deal” or “data”, whatever :-)

As for how the AJAX is pulling down data, I’m just using inner­HTML, because it works in pretty much every­thing and is lots faster and lots sim­pler than “real” DOM meth­ods, espe­cially here. Observe the “Details” pane on the right of that page, and how there are dif­fer­ent num­bers of para­graphs of text, dif­fer­ent types of data (lists, anchors, etc.), then con­sider how ridicu­lous it would be to use DOM script­ing there. Euu­u­uc­cch. So, I’m not-quite stan­dard but per­fectly com­fort­able about that. I am, how­ever, using HTML 4.01 as the doc­type. There is no rea­son to use XHTML, and I’m not happy to use XHTML and not serve it prop­erly. And, if I serve it prop­erly, it’s too likely to break (parsers spit the dummy when encoun­ter­ing bad XHTML, because tol­er­ance is zero) for a pro­duc­tion site. Fur­ther, obvi­ously, inner­HTML doesn’t work when doc­u­ments aren’t served/parsed as any­thing other than text/html.

I’d rather do absolutely awe­some HTML 4.01 than valid but mediocre (and ulti­mately point­less, see­ing as it’s not being parsed as XML even) XHTML.

In other nifty technology-related stuff, Yahoo!7’s part­ner­ship means (hope­fully) that Seven will up the ante in terms of what tech­nolo­gies they’re unfurl­ing. For us, this means tak­ing a step for­ward and pro­vid­ing syn­di­ca­tion ser­vices (both Atom and RSS for­mats) for the deals. For Seven as a whole? Well, maybe they’ll start to get rid of their once-ubiquitous table-based lay­outs, and (maybe) embrace more of an open broad­cast­ing par­a­digm in line with their web strat­egy — assum­ing Yahoo! are direct­ing that in any way, and/or that Seven’s online team have open minds — I don’t really know and haven’t per­son­ally dealt with any­one there, so I’ll just assume they must have a hand­ful of cluey peo­ple on board!

The RSS and Atom feeds won’t be avail­able if you’re check­ing it out on Mon­day, but it’ll likely be run­ning by the end of the week. For Yahoo! users, this means they can add Sun­rise Fam­ily Deals to their per­son­alised page (but, seri­ously, who uses por­tals? I never under­stood that whole thing). For every­one else, you should be able to down­load a feed reader and add the feeds. I’d love to have a page telling peo­ple how to do this on the site, but imag­ine Yahoo! would object. So I’m say­ing it here: the peo­ple that mat­ter know how to do it! (Though, I imag­ine, the “peo­ple that matter” — you, dear reader — aren’t par­tic­u­larly reg­u­lar Sun­rise view­ers. Or, like me, never Sun­rise view­ers. Heh.)

We’ve also imple­mented a spot of JavaScript to fix text-selection in Inter­net Explorer. My lay­out is pretty insane in terms of the sheer quan­tity of absolutely posi­tioned ele­ments, which broke that func­tion­al­ity in Inter­net Explorer. One quick ques­tion to the WSG mail­ing list later, some­one had pro­vided a JavaScript fix (which we had to edit a lit­tle bit to make work prop­erly, because we had prob­lems with flick­er­ing ele­ments even with cache enabled).

The eye-candy

I’ve imple­mented use­less (but rather cool) eye-candy on the Deals page in the Details pane when­ever a new deal is selected. A vari­a­tion of the Fade Any­thing Tech­nique, which is only meant to be pretty. No orig­i­nal­ity is claimed, we’ve had this tech­nol­ogy all millennium.

Acces­si­bil­ity

Dis­able JavaScript and you lose the fades, and use a lit­tle more band­width as the entire page reloads for every item you click. In terms of non-visual user agents with JavaScript dis­abled, I’ve put the “Details” above the list of offers in source-order, and on every reload they only hear “Sun­rise Fam­ily. Link: Skip to main con­tent” (pre­sum­ing they select the link) before get­ting to the actual details, so I’m fairly happy on that front.

Addi­tion­ally, I’ve got the “header” from Yahoo!7 last in source-order, so any­one with assis­tive tech­nolo­gies don’t have to skip over that EVERY TIME they change the page. It was a lit­tle painful to fig­ure out, not in the least because Yahoo’s sup­plied uni­ver­sal header isn’t at all nice for sites that are built prop­erly — i.e. with web stan­dards and acces­si­bil­ity in mind — but I much pre­fer it this way. This is also some­thing we had to achieve silently and with­out com­plain­ing, because, whilst any­one who has a clue about web acces­si­bil­ity will imme­di­ately see this is a good idea, mar­ket­ing peo­ple would con­ceiv­ably think: “But we want peo­ple to see our search bar more often!”. Er, no, you don’t achieve any­thing by piss­ing off users. No mat­ter, we pulled it off with­out mak­ing any noise about it!

We’re server-side sniff­ing for Fire­fox and hand­ing it an “Add Yahoo!7 to the Fire­fox Search Box” link (which, inci­den­tally, has par­tic­u­larly hor­rid inline JavaScript — but I don’t care because the only UA it’s being served to can do some­thing use­ful with it), whilst IE users get a “Make this my home­page” link in its place. Yahoo’s ver­sion (which you can see on Seven’s — pure Flash, *oblig­a­tory shud­der* — Aus­tralian Open web­site, though I think that ver­sion (of the header, not the web­site) might now be dep­re­cated) uses JavaScript for that, but it was fairly obtru­sive and, see­ing as we have the abil­ity to do that server-side, I’d much rather reduce page weight.

In terms of acces­si­bil­ity gen­er­ally speak­ing, I’ve bun­dled in all the usual good­ies such as a skip to main con­tent link, as well as skip to login on the front page, base font size of 100.01%, and rel­a­tive font siz­ing through­out… but exten­sive image replace­ment tech­niques mean that the head­ers are prob­a­bly sub-optimal in terms of vis­i­bil­ity. This one is out of my con­trol, and every­one else in the work­place seems to love small text (even Lyn, who seems to often put on glasses to read things on a screen… go fig­ure!) so I wasn’t going to fight too hard about it. All other text will scale pretty well, with the excep­tion of the deals — because the lay­out is so tight, it’s only really pos­si­ble to go up one, maybe two size steps in most browsers.

We’re lack­ing any explicit acces­si­bil­ity state­ment, and we’re also lack­ing access keys. Mostly because I’m con­vinced access keys are prac­ti­cally use­less, and rarely bother to imple­ment them. (On forms, there are never enough but­tons for access keys and/or there’s no log­i­cal com­bi­na­tion avail­able, and every­where else it sort of seems a bit point­less unless every­thing has an access key. Where do you draw the line?)

This site is inter­est­ing to me because, even though it’s a tele­vi­sion audi­ence, I still can’t make assump­tions about how peo­ple will be brows­ing. PDA devices, for exam­ple, would strug­gle with our built-for-1024 lay­out had we done it with tables. For this site, PDA/mobile users are real­is­tic: for exam­ple, if some­one inci­den­tally is near a Wendy’s store and remem­bers they might’ve seen some­thing on the Sun­rise web­site but can’t remem­ber the details, they can quickly and pain­lessly look it up.

Fur­ther, the site also has to cater for peo­ple with cog­ni­tive or motor dis­abil­i­ties. For cog­ni­tive dis­abil­i­ties, one thing in our favour is that we’ve pro­vided a short sum­mary of each deal before a more heavy-duty full­text item. For users with motor dis­abil­i­ties, the entire web­site should be acces­si­ble via tab­bing — includ­ing the JavaScript-enabled Deals page.

I lost an argu­ment regard­ing target=“_blank”, but will even­tu­ally win this point. A hand­ful of adver­tise­ments — includ­ing those for intra-network links, such as for the Seven Store — open in new win­dows, which I am most cer­tainly not a fan of. All exter­nal links, how­ever, should have the rel attribute set to exter­nal. There is unfor­tu­nately no visual cue asso­ci­ated with this. Links I count as my biggest area of defeat in this web­site, which is pretty good (as in, I’d rather it just be that than some­thing more sig­nif­i­cant such as iframe usage, enor­mous usabil­ity prob­lem though new win­dows may present).

Inline JavaScript is com­pletely unre­lated to acces­si­bil­ity in light of the way this has been imple­mented. Admit­tedly, it would be advan­ta­geous to use event han­dlers in place of inline JavaScript (and we will be think­ing that to our­selves as we look at the traf­fic sta­tis­tics), but from an acces­si­bil­ity per­spec­tive it has very lit­tle impact. Stan­dard HREF’s are defined, and caught with Javascript using return false; No func­tion­al­ity is lost. I much pre­fer this method to scat­ter­ing iframes through­out the site! At any rate, I’m still try­ing to resolve this one, acces­si­bil­ity related or not. It’s a mat­ter of per­sonal pride, I suppose.

The Styles and Bugs

The entire design (done in-house by Dacien) is awe­some (in my opin­ion — if I didn’t think it was, I just would have kept quiet about it), but very tight.

So tight, in fact, that I had to set outline:0; on some links to stop Fire­fox from break­ing the lay­out (1 pixel dif­fer­ence) when a link was active (as they are when you click a deal and it’s caught by JavaScript rather than actu­ally reload­ing the page — the link remains active), adding a 1 pixel dot­ted bor­der. Cross browser sup­port is pretty awe­some — it should be good in IE back to 5 — Opera, Safari, Kon­queror, and even (mostly) IE 5.2 Mac are happy. Fire­fox deserves spe­cial men­tion: it has so many lit­tle (big for this site) things wrong with it that it’s often rather painful to make work prop­erly. In fact, of all browsers men­tioned, Fire­fox 1.0.x (on non-Windows plat­forms) is the only one whose behav­iour I’m def­i­nitely not happy with (mostly because I expect bet­ter from it, but also because it gets some things hor­ri­bly wrong).

Such as, for exam­ple, the “Meet the Fam­ily” page. It works per­fectly or near-perfectly in every other browser, but cer­tain Fire­fox vari­ants on cer­tain plat­forms ren­der only the first two items in the “Sun­rise Team” list(/right col­umn, if you’ll excuse my presentational-speak) on first load… and then ren­ders per­fectly if you refresh the page. This is what I meant by my “pre­dictable inad­e­quacy” post of a few days ago. I’m fairly cer­tain it’s some­thing to do with floated list items, but pos­si­bly not.

Another bug is (also in Fire­fox — notic­ing a trend, any­one? No, I didn’t build for IE. I wrote about 90% of the stylesheet sit­ting in Fire­fox 1.5.x using Chris Pederick’s Web Dev exten­sion, and both that browser and Opera oper­ate near-perfectly) Fire­fox 1.0.x’s pen­chant for adding scroll­bars where they’re not required with overflow:auto (see front page on non-Windows plat­forms, and the Deals page — lots of style overlap/common classes there, so this is to be expected).

By far the most inter­est­ing ren­der­ing dif­fer­ence I encoun­tered build­ing a lay­out this tight was between Inter­net Explorer/Windows XP with and with­out Win­dows Themes enabled. Yes, it does make a dif­fer­ence. Inter­face wid­gets shouldn’t really inter­fere with styles at all, IMO, but they did here. The solu­tion basi­cally entailed shav­ing off a cou­ple of pix­els where required, so I didn’t come up with some­thing par­tic­u­larly inno­v­a­tive for it!

Sum­mary

In all, I’m pretty happy with the site. Seven’s inter­nal Online team appar­ently noticed/complimented our team on the absence of lay­out tables, which I (per­haps arro­gantly) take with some degree of indif­fer­ence: peo­ple shouldn’t be build­ing sites with tables for that pur­pose any­way. If we are to be com­ple­mented, then it should be on the design (and, as part of that, achiev­ing a design this ‘tight’ with CSS), or on the usabil­ity ben­e­fits realised by intel­li­gent inte­gra­tion of AJAX, or the devel­op­ment pace (again, par­tially because of the flex­i­bil­ity CSS gives us), or maybe on light­weight, seman­tic code as a cost-saving mechanism.

Truth be told, I now believe we may have even gone a lit­tle over­board with the tables elim­i­na­tion. If I could do it all again, the Deals page would fea­ture a table instead of a list, and I’d use DOM script­ing to insert/delete records rather than replace the “state” part with inner­HTML. The markup might gain a (very) lit­tle bit of weight, but it’d be worth it. It would, of course, remain seman­ti­cally sen­si­ble and com­pletely acces­si­ble. It’d prob­a­bly be more seman­ti­cally sen­si­ble, actu­ally. I realised a table would work great about two days after I’d fin­ished styling the list, and thought “I’ve put way too much effort into this to pull it now”, but felt like Dave Shea must have after build­ing a “pseudo table” with­out real­is­ing. At least it wasn’t that complex!

Any­way, I’m really inter­ested to hear what peo­ple have to say about the site. We’re being plugged every half hour on Sun­rise tomor­row morn­ing from 6am, and will be anx­iously watch­ing the server to see what, exactly, the effect of pro­mo­tion on a show with 4 mil­lion view­ers daily has on band­width, etc. I’ve also installed an AWstats tracker to col­lect aggre­gate data (as on this site) which we’ll parse later on (assum­ing the hor­ri­ble mon­ster that it’s run­ning on, Zeus, out­puts normal-ish log files for me! Oh, and it doesn’t sup­port mod_rewrite, but instead has some retarded alter­na­tive that seems like a cross between VBA and Apple­Script — and fails as much as the lat­ter did in terms of actual ease of use, despite try­ing to use human lan­guage. It’s very dumb.) to fig­ure out how Aus­tralia is doing in terms of browsers, oper­at­ing sys­tems, screen res­o­lu­tions, JavaScript sup­port, and the like. Should be incred­i­bly inter­est­ing stuff, and I can’t wait!

The Single IE Linebreak Through [optionally transparent] Proxy Character Encoding Bug

It’s new, so far as I’m aware, and I can’t even build a decent test case for it. In one instance alone, if there’s a blank line between two ele­ments (i.e. just for read­abil­ity, doesn’t need to be like that), then cer­tain ver­sions of IE — and only when their traf­fic is being prox­ied through cer­tain transparent/non-transparent servers — will dis­play a blanking/“unknown” character.

At first it was thought this was just because of a dud char­ac­ter in a file, but then we tried using PHP to echo \n\r, \n, and \r in the place of a man­u­ally entered return: all of which resulted in the bug per­sist­ing. The only fix I’ve got is to use an HTML com­ment between lines

</element><!--
--><another element='element'>

Like that. Any­thing else, and we get a blank­ing char­ac­ter in there. Bizarre!

It doesn’t occur any­where else on the site in ques­tion, and I’m not going to waste hours try­ing to build another un-branded test case which may or may not work! The prob­lem affects IE only (though we didn’t do ver­sion test­ing), and only when traf­fic is going through (some) proxy servers. And only that one character.

It’s not an encod­ing prob­lem per-se, though is obvi­ously related to that in some sense. This is still internal-only, and it’s not being dished up with proper content-types defined in HTTP head­ers (because I’m still liable to change my mind as to how that should be done, and I’m not call­ing it until the site is about to launch/what is/isn’t required in terms of content-type – affected things is abun­dantly clear!), but see­ing as it only has an impact when using through a proxy it’s pretty obvi­ous it’s not JUST here. Shrug. I reluc­tantly deleted the line­break and the box went away.

# by Josh on January 24th, 2006 Tags: , ,
| No Comments »

Brilliant anti-AJAX comment

Pinched in full­text from a com­ment on a post regard­ing Web 2.0 (orig­i­nally writ­ten for FT, so it’s not par­tic­u­larly geeked out).

Such pages, how­ever, tended toward dull­ness and infre­quent updating.

Or, to put it another way: Such pages tended to ful­fill the orig­i­nal vision of the Web, which was to allow absolutely any­one to pub­lish infor­ma­tion that might oth­er­wise be lost to the pub­lic, in a way that allows it to be searched, indexed, book­marked, and linked to related infor­ma­tion. And accessed by absolutely any­body who’s look­ing for it.

As opposed to today’s “dynamic” Web, where you need a broad­band con­nec­tion, an industrial-grade graph­ics work­sta­tion, and more plug-ins than a Roman orgy just to look up the atomic weight of molyb­de­num. Which you can’t book­mark because the URL is a dynamically-generated con­glom­er­a­tion of the host­name, your ses­sion ID, the phase of the moon, and the bra size of the webmaster’s cur­rent girl­friend, that doesn’t point to a page that’s actu­ally stored on disk somewhere.

As nifty as it is that peo­ple have found new ways to make use of HTTP and HTML, we seem to be slowly los­ing the very con­cept of “pub­lish­ing” as “pre­serv­ing a record of today for future recall”. Instead of being the equiv­a­lent of an “address” where one can “go” to retrieve infor­ma­tion, the URL has become a “magic incan­ta­tion” that instructs a dis­tant server to per­form some action that may or may not pro­duce the same results as the last time it was used.

In some ways, that’s good: it’s nice to be able to use the same mech­a­nism to say “Bring up the lat­est edi­tion of Dan’s blog”, “Show me the cur­rent pres­sure and tem­per­a­ture read­ings of Injec­tion Molder #7″, and “Dis­play page 7 from our company’s 2003 annual report”.

But there’s some very scary Orwellian poten­tial here, as well as the risk of exac­er­bat­ing the Dig­i­tal Divide by con­stantly ramp­ing up the min­i­mal plat­form needed to access much of the web. Those librar­i­ans Dan men­tioned lately shouldn’t be the only ones wor­ried about mak­ing sure that a large per­cent­age of online con­tent remains “dull” and “static”.

I think the “Orwellian poten­tial” bit is a load of scare-mongering crap (in rela­tion to the other con­cerns posed in the arti­cle, at any rate), but every­thing else rings true.

I am, at present, work­ing on the first large-scale project I’ve been involved in where <a href=“http://en.wikipedia.org/wiki/AJAX/ title=“Asynchronous JavaScript and XML”>AJAX is being utilised. In this instance, yes, it was my call: yes, I do feel it’s jus­ti­fied (rea­sons include traf­fic, and the advan­tage of not hav­ing to reload an entire page — yes, it’s large scale enough for that to be sig­nif­i­cant — and sim­ple usabil­ity, because the archi­tec­ture is such that users will desire to move quickly between ele­ments of con­tent, and AJAX facil­i­tates that. More details post-release). We’ve been very care­ful to pre­serve func­tion­al­ity in non-XMLHttpRequest enabled UA envi­ron­ments, but it’s still not per­fect — book­mark­ing is one (minor, given the nature of the con­tent) prob­lem that still requires rec­ti­fi­ca­tion: that’s one thing I’m hop­ing to resolve tomor­row (along with gen­eral CSS com­pata­bil­ity back to IE 5, pos­si­bly 4 — but that’s not par­tic­u­larly rel­e­vant). The Javascript is not par­tic­u­larly “unob­tru­sive” (still using inline onclick), which I’m hop­ing to sim­i­larly resolve prior to launch, but it’s not of any par­tic­u­larly great consequence.

This is not a site to be archived, as the author of the com­ment above laments. But he shouldn’t. That wasn’t ever this site’s pur­pose, so I’m not par­tic­u­larly con­cerned if the markup isn’t pres­tine. Yes, there will be RSS/Atom syn­di­ca­tion. It’s a fairly Web 2.0 buzzword-compliant site, though (I hope) not par­tic­u­larly unnec­ces­sar­ily adop­tive of such tech­nolo­gies. We’ll see.

A reminder of why semantic HTML and CSS rock, from an unlikely source

Pho­to­shop, graph­ics heavy-weight app that it is, does not feel like it should ever be used for web design pro­to­typ­ing. I’m new to this whole gig, hav­ing used the GIMP for sev­eral years now (on and off since 2001) but even that is still a graph­ics appli­ca­tion and not… a web one.

On a small-ish site, even a minor change becomes hell­ish — some­one asked me to change the font size down a bit, which of course involved going to TOO MANY BLOODY LAYERS and man­u­ally adjust­ing the font size. And don’t even ask about form con­trols… Mock­ing that up involves lay­ers, place­ment… but none of it synced to the font size. So when I change the font size, the forms of course are all out of position.

CSS… I change two dig­its and the entire site changes along with them. Magic.

p.s. Oh, yeah, and how the hell do you markup a TABLE in Pho­to­shop? Dumb dumb dumb!

# by Josh on December 13th, 2005 Tags: ,
| 6 Comments »

The Picture of Dorian Gray quotes

Just for fun. And because Google prob­a­bly won’t get this indexed until after the Exten­sion Eng­lish exam tomor­row com­mences, which means the only peo­ple likely to see this in time are those who go to my school anyway ;-)

At any rate, good luck to any­one who feels like try­ing to mem­o­rise any sub­stan­tial­ish chunk of this by tomorrow…

With­out fur­ther ado, quotes in PDF for­mat. (53.1KB)

Thumbnail of PDF

If you want full­text, Project Guten­berg has a nice HTML ver­sion (bet­ter than plain text because it’s not scat­tered with stu­pid linebreaks).

# by Josh on October 30th, 2005 Tags: , , ,
| 2 Comments »

The attribute myth

I’ve been talk­ing with Ben this evening about… markup, amongst other things, and dis­cov­ered a con­vic­tion that using sin­gle quotes with an attribute is evil.

Clear­ing this up right now: it’s not, either in HTML 4 or XHTML (which retains much of the seman­tics of HTML 4, except where explic­itly con­tra­dicted — “The seman­tics of the ele­ments and their attrib­utes are defined in the W3C Rec­om­men­da­tion for HTML 4. These seman­tics pro­vide the foun­da­tion for future exten­si­bil­ity of XHTML.”). Sec­tion 3 of the HTML spec­i­fi­ca­tion states:

By default, SGML requires that all attribute val­ues be delim­ited using either dou­ble quo­ta­tion marks (ASCII dec­i­mal 34) or sin­gle quo­ta­tion marks (ASCII dec­i­mal 39). Sin­gle quote marks can be included within the attribute value when the value is delim­ited by dou­ble quote marks, and vice versa. Authors may also use numeric char­ac­ter ref­er­ences to rep­re­sent dou­ble quotes (&#34;) and sin­gle quotes (&#39;). For dou­ble quotes authors can also use the char­ac­ter entity ref­er­ence &quot;.

Ben didn’t quite get the “Sin­gle quote marks can be included within the attribute value when the value is delim­ited by dou­ble quote marks, and vice versa.” bit, so here’s a quick exam­ple of both:

<img alt="If you can see this, the image isn't working" />
<img alt='You can probably see this because the "src" attribute is not defined' />

Both are valid and should work fine (with the excep­tion of the lack of src, obvi­ously). Feel free to use sin­gle or dou­ble quote marks, safe in the knowl­edge nei­ther is bet­ter than the other.

# by Josh on October 24th, 2005 Tags: , ,
| 5 Comments »