Posts from 2007

Inherit Expression for IE?

Published 17 years, 7 months past

The reset styles are currently held up on a point of non-support in IE/Win.  However, there’s a decent chance we can work around it.  I’m hoping you (or someone you know) can help.

One of the things I indicated was problematic, but that I would keep, was the use of inherit for a few properties.  This value isn’t supported by IE/Win, and while I’m okay with including it anyway, it could cause confusion for others trying to use my reset styles.

Priit Pirita suggested the use of IE expressions to simulate inheritance.  For example:

 font-style: expression(
   this.parentNode.currentStyle ? 
   this.parentNode.currentStyle.fontStyle : 
   ‘normal’);

That would assign the weight of the parent element for any element whose parent had a currentStyle, and fall back to normal in any case where that wasn’t true.

Cool enough, assuming you’re okay with using expressions, but there are a couple of wrinkles I haven’t quite worked out.  The first is this:

 font-family: expression(
   this.parentNode.currentStyle ? 
   this.parentNode.currentStyle.fontFamily :
   ‘[...???...]’);

What should be filled in for the [...???...]?  The font family that IE/Win uses by default when first installed?  A null value?  Something else?  I dunno.  Hopefully someone here does.

The second problem is that some people have reported errors generated by expressions; see this comment by thacker for an example.  Can anyone explain why those errors happen and how to avoid them?

The end goal here is not only to come up with inherit equivalents for font-weight, font-style, and font-family, but also to come up with a generic method of simulating inherit for any property.  Doing so would be an enormous boon to developers, so here’s hoping we can pull together and solve this puzzle.  Thanks!


Reset Reasoning

Published 17 years, 7 months past

The reset styles are undergoing yet another overhaul, but in the meantime, I thought I’d answer a question several people have asked: why?!?  Why do this at all?

The basic reason is that all browsers have presentation defaults, but no browsers have the same defaults.  (Okay, no two browser families—most Gecko-based browsers do have the same defaults.)  For example, some browsers indent unordered and ordered lists with left margins, whereas others use left padding.  In past years, we tackled these inconsistencies on a case-by-case basis; for example, making sure to always set both left padding and left margin on lists.

But there are all kinds of inconsistencies, some more subtle than others.  Headings have slightly different top and bottom margins, indentation distances are different, and so on.  Even something as basic as the default line height varies from one browser to another—which can have profound effects on element heights, vertical alignments, and overall feel.

This is not something we consider very often.  We think of our CSS as modifying the default look of a document—but with a “reset” style sheet, we can make that default look more consistent across browsers, and thus spend less time fighting with browser defaults.  Rather than say “the size of that heading is just right”, forgetting that not all browsers size headings the same way, I have to write the CSS that sets the heading to be the size I want (or the design requires, which comes to the same thing).

This is why so many people zero out their padding and margins on everything by way of the universal selector.  That’s a good start, but it does unfortunately mean that all elements will have their padding and margin zeroed, including form elements like textareas and text inputs.  In some browsers, these styles will be ignored.  In others, there will be no apparent effect.  Still others might have the look of their inputs altered.  Unfortunately, there’s just no way to know, and it’s an area where things are likely to change quite a bit over the next few years.

So that’s why I don’t want to use the universal selector, but instead explicitly list out elements to be reset.  In this way, I don’t have to worry about munging form elements.  (I really should write about the weirdnesses inherent in form elements, but that’s for another day.)

There’s another reason I want to reset a whole lot of styles on a whole lot of elements.  Not only do I want to strip off the padding and margins, but I also want all elements to have a consistent font size, weight, style, and family.  Yes, I want to remove the boldfacing from headings and strong elements; I want to un-italicize em and cite elements.

I want all this because I don’t want to take style effects for granted.  This serves two purposes.  First, it makes me think just that little bit harder about the semantics of my document.  With the reset in place, I don’t pick strong because the design calls for boldfacing.  Instead, I pick the right element—whether it’s strong or em or b or h3 or whatever—and then style it as needed.

The maddening barrier to this is, yes, Internet Explorer.  See, in order to set all elements to have the same font weight and style (both normal) and have all elements use the same font face without breaking inheritance, I need to declare the following:

font-weight: inherit;
font-style:  inherit;
font-family: inherit;

But IE/Win doesn’t support inherit, which would seem to bring that whole effort to a screeching halt.  I can’t explicitly assign the values, like I did in a previous version of the style sheet, because that would block the effects of inheritance.  Say, for example, I wrote this instead:

font-weight: normal;
font-style:  normal;
font-family: serif;

Okay, now I have this rule later on in the CSS:

h1 {font: bold 2em Verdana, sans-serif;}

Then I have this markup:

<h1>Considering a <em>Truly</em> Annoying Omission</h1>

The em in the middle of the h1 will be un-boldfaced, and in a serif face.  With the inherit values, it would be bold and in Verdana (or some sans-serif font).  I should have realized that from the outset, but sometimes my enthusiasm gets ahead of my reason.

So do I drop those inherit declarations?  In the end, no.  They won’t work in IE/Win, but since I develop primarily in Firefox and Safari, that’s not actually a problem.  Their effects, as seen in my development environment, will still serve the purpose of reminding me to build up the styles I actually want, and not use the browsers’ defaults as a crutch.  There is the possibility of my forgetting that (for example) IE/Win italicizes em when I don’t want it to, but that’s something I’ll catch during the browser testing phase.

Hopefully this helps clarify my motivations and thinking.  I’ll follow up with a new (and hopefully final) version of the reset styles in another post, along with commentary on what other things I changed.


Sound of a Gun

Published 17 years, 7 months past

This morning, the local NPR station devoted an hour to the psychological effects of a campus shooting.  Four years ago, there was a shooting on the Case campus in which one person died, so they had members of the Case counseling staff talk about how they helped affected people cope on and with that day.

The first caller I heard on the program did exactly what I knew someone was going to do: he said that the tragedy would have been much more limited in scope if others had been armed, if students and faculty and ordinary citizens routinely carried concealed weapons.  The very next caller, inevitably, put forth the view that stricter gun controls would prevent such tragedies from ever happening.

In both cases, the host cut the calls short, saying that the goal was to talk about the psychological effects of campus shootings, not start a debate on gun control.  But that’s exactly what was happening.  Those people were trying to mitigate their personal sense of horror by focusing on ways to fix some underlying problem, to prevent such things from ever happening again.  They were trying to make the unthinkable thinkable.

It’s understandable.  We’re a results-oriented, can-do-focused society.  And by locking our attention on what we fervently believe to be solutions, we can shut out the grief that we feel for strangers miles and miles away, ignore the horror and anger that wells inside us.

So far as I know, nobody I know has even a tenuous connection to the events in Virginia.  But all I can think of is the parents, children, spouses, and relatives who will never see their loved ones again.  In my throat, I feel a faint shadow of the freezing, nauseating grip of despair and anguish they are experiencing.  Behind my eyes, there is an echo of the ache of tears that will not come because shock has stopped them cold.  In my guts, there is a small tear that mimics the gaping, ragged void that must be felt by a parent whose child is suddenly dead.

These dead are not my dead… but they are all our dead.

Some other day, perhaps, it will be a time to think about and discuss ways to fix whatever problems lead to or permit such horrors.  Perhaps.  Today I mourn those who died and the death of all their hopes and plans.  I grieve for those left behind to cope with a shattering new reality.  It is not what we’re taught to do, but it is the most human thing any of us can do.  We forget that too easily.

It is no solution, but for me, this is not a day for solutions.  It’s a day of sorrow.


American Express Limited After All

Published 17 years, 7 months past

Anyone remember the American Express commercial where a guy talks about how he was at a big client dinner and his credit card got declined?  “I was so embarrassed,” the voice actor moans, and then goes on to relate how his father told him to get an American Express.  With no pre-set spending limit, he informs us, he’ll never have to worry about being declined again.

Wrong.

It turns out that “no pre-set spending limit” does not mean “you can charge as much as you want as long as you pay off the balance on time”.  It means “your monthly spending ability changes based on your spending history”.  You can absolutely have a charge to your AmEx declined.  Even better, since the limit changes continually based on your activity, you have no reasonable way to know when a decline might happen.  It’s the worst of both worlds!

All this, and an annual fee to boot.  Awesome!  Where do I sign?

Of course, when you think about it, you quickly realize that there had to be some kind of limit.  If there weren’t, you could buy a fully armed jet fighter with it.  (Which would of course be awesome.)  What rankles is that the advertising explicitly claims, and the wording “no pre-set spending limit” strongly implies, that declines are a thing of the past with an AmEx—which is completely and utterly false.

Fortunately, it seems that there is a way to handle charges that exceed your spending limit: pre-pay the charge(s) in question.  Of course, I had to think of this and ask someone at AmEx about it; the three people I’d talked to before that hadn’t volunteered the information, or else just didn’t think of it.  I’ve been assured that, having paid in advance, everything will go through without incident, even though what I’m charging is about an order of magnitude greater than the initial spending limit set for the card.  We’ll see how things play out.

I just wish they’d been more open about all this in the first place.  As a result of all this, it’s difficult to shake the feeling that my new card issuer has been lying to me.  That’s not really the way I prefer to start a new relationship.

Anyway, I just thought I’d share this little tidbit for the benefit of anyone interested, including any future Googlers.  Oh, and vent a bit in the process.  That always feels good.


A Question of Identity

Published 17 years, 7 months past

Over the weekend, I reworked meyerweb’s sidebar a bit.  One of the changes is the addition of a section called “Identity Archipelago“, which links to various bit of my online identity and makes use of XFN‘s me value.  I’ve been meaning to do this ever since co-presenting a poster on how me could be used to accomplish identity consolidation, and hey, I’m only thirty months late.

I ran into an interesting dilemma as I assembled the links, though.  Should I link to the Wikipedia entry about me, and if so, does it really merit a me marker?  I’m not so sure.  Yes, the page is about me, but it isn’t something I created, nor is it something I control.  Thanks to the open nature of Wikipedia, it could be altered to state that I’m a paste-eating pederast with pretensions to the Pakistani presidency.  It would be kind of embarrassing to link to something like that, let alone proclaim in a machine-parseable way that the information on the other side of the link represented me in some way.

While I’ve never stated a Wikipedia policy, as others have, I’ve privately maintained a hands-off policy.  Even though I’d like to replace the picture with a better one and flesh out some details of my career, and on occasion have wanted to correct some inaccuracies, I’ve refrained from doing so.  I’m not going to proclaim that I’ll never ever edit my own entry, because if libel (alliterative or otherwise) shows up and I’m the first to notice, I’ll at least roll the page back.  But in general, I’m keeping my hands off.

Nevertheless, it is arguably a piece of my online identity.  Not linking to it feels like a glaring omission—or am I just trying to rationalize an egocentric desire to show off?  I don’t think that I am, but then I’m hardly a neutral party.

So what’s your perspective?  Is a Wikipedia entry created and edited by others properly a part of my archipelago, or is it simply a nearby island?


XBox Live via an Airport Express?

Published 17 years, 7 months past

Thanks to the faintly odd generosity of a colleague—I won’t name names, but let’s just say the URL of the gentleman in question rhymes with “fairgag”—I find myself with a yearlong XBox Live subscription.  One interesting wrinkle in this scenario is that I don’t really have any multiplayer games besides Halo 2, but that isn’t really the biggest issue.  No, the real problem is that the XBox 360 is two floors away from the DSL router, with no possible cable routes that don’t involve winding about a hundred feet of CAT-5 around stairwell bannisters and across public walls.

Now, I do have 802.11b wifi in the house, so I could buy the official wifi adapter.  What I’m wondering, though, is if I could plug the XBox into my Airport Express‘ Ethernet port (or the USB port) and get it onto the network that way.  I Googled a bit but didn’t turn up anything relevant, and poking around the administration utility’s configuration pages didn’t seem to help.  Anyone know if there’s a way to make this happen?

Of course, I have no idea if my Netgear MR814v2 router is even XBox Live compatible, but one thing at a time, I guess.


Reworked Reset

Published 17 years, 7 months past

Here’s the latest version of my “baseline” style sheet, with some changes based on feedback from readers on the original post.

/* Don't forget to set a foreground and background color 
   on the 'html' or 'body' element! */
html, body, div, span,
applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dd, dl, dt, li, ol, ul,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
	margin: 0;
	padding: 0;
	border: 0;
	font-weight: inherit;
	font-style: inherit;
	font-size: 100%;
	line-height: 1;
	font-family: inherit;
	text-align: left;
	vertical-align: baseline;
}
a img, :link img, :visited img {
	border: 0;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}
ol, ul {
	list-style: none;
}
q:before, q:after,
blockquote:before, blockquote:after {
	content: "";
}

The changes are:

  1. The leading comment — rather than fill in some default document colors, which I hesitate to do given how often they’ll be changed, I just threw in a comment reminding the author that setting them is a good idea.  I’d expect that anyone who uses their own set of baseline styles will fill in their own favorite color set.

  2. font-weight: inherit; — this used to be normal, but it was pointed out that this would upset normal inheritance.  For example, if you set a div to be boldfaced, none of its descendant elements would inherit that boldness (because they’d be explicitly assigned normal).  Using inherit avoids this problem while still “zeroing out” boldface styling.

  3. font-style: inherit — same reasoning.

  4. vertical-align: baseline — this brings everything onto the baseline, including superscripts and subscripts.  This forces authors to determine the exact vertical offset they want for such elements, as well as any others they might care to vertically shift, as well as how they’ll accomplish said shift(s).

  5. a img, :link img, :visited img — this will make sure images in anchors and links don’t have a border by default.  Using a img covers images in named anchors, while the rest of the selector handles images inside either visited or unvisited links.  You might consider a img to be sufficient, and for now you’d be right.  But in the future, any element may be a link, not just a elements, so this gives us a bit of future-proofing.

I also put some spaces into the selectors to make them easier for me to read.  If you use these styles, you might consider stripping out the unnecessary whitespace to compact the rules as much as possible.

It was suggested that min-width: 0; be added to the first rule in order to invoke hasLayout, but Ingo Chao explained why that was a bad idea.  It was also suggested that text decorations should be removed from links, but I’d rather not.  I try never to mess with link decorations, and also figure that anyone who feels otherwise can add their own text-decoration declarations.

So we’ll see how well this one stands up to use in the wild.  Let me know!


Reset Styles

Published 17 years, 7 months past

At AEA Boston, I advocated using a “reset” or “baseline” set of styles, but not one based on the universal selector.  Instead, I said the styles should list all the actual elements to be reset and exactly how they should be reset.  During the Q&A afterward, an audience member asked me if I would create such a style sheet to share with the world, and I said that I would.

Then, during the break, someone else (sorry I’ve forgotten who!) reminded me that the Yahoo! UI group already did it with reset.css so I don’t have to.  Awesome!

…except that I don’t think it goes far enough in some areas, and a little too far in others.  So here’s my version of reset.css, based off of the YUI styles.

html,body,div,span,
applet,object,iframe,
h1,h2,h3,h4,h5,h6,p,blockquote,pre,
a,abbr,acronym,address,big,cite,code,
del,dfn,em,font,img,ins,kbd,q,s,samp,
small,strike,strong,sub,sup,tt,var,
dd,dl,dt,li,ol,ul,
fieldset,form,label,legend,
table,caption,tbody,tfoot,thead,tr,th,td {
	margin: 0;
	padding: 0;
	border: 0;
	font-weight: normal;
	font-style: normal;
	font-size: 100%;
	line-height: 1;
	font-family: inherit;
	text-align: left;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}
ol,ul {
	list-style: none;
}
q:before,q:after,
blockquote:before,blockquote:after {
	content: "";
}

I omitted elements like hr and the various frame-related elements, as well as form elements like input and select, because of their general weirdness, though I may change my mind about those at a later date.  I intentionally left out dir and menu because of their deprecated status.

I’m absolutely open to questions, comments, and suggestions, so feel free to use the comments for that purpose.

(Side note: if anyone’s disturbed by the unitless value for line-height, please read my post “Unitless line-heights“.)

Addendum: There have been some good suggestions in the comments, so they’re definitely worth reading.  See also the followup post, which incorporates some of those suggestions.


Browse the Archive

Earlier Entries

Later Entries