Posts in the Tech Category

Reset Reasoning

Published 18 years, 1 month 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.


A Question of Identity

Published 18 years, 1 month 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?


Reworked Reset

Published 18 years, 1 month 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 18 years, 1 month 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.


Stylish Spam

Published 18 years, 1 month past

From my comment queue, possibly the first time I feel a spammer is really speaking to me as a person:

Did u ever heard about CSS…? it will help your site.

Do tell, oh random anonymous stranger whose site URL crudely references the genitalia of older females!  I wish to learn.


After Boston

Published 18 years, 1 month past

Wow.

Just wow.

I’m back home and I still can’t believe how amazing An Event Apart Boston was for me and everyone with whom I talked.  I knew going in it was a great lineup of speakers covering great topics.  I knew that we had a completely kick-ass staff in place, and amazing volunteers to help us out.  I knew that we’d have great support from the venue.

I knew all that, and I was still overwhelmed and ecstatic at how things went.  At least on one level.  On another, thanks to the aforementioned kick-ass staff, things went so smoothly that I almost felt like I was a speaker at someone else’s conference.  I had so little to worry about that it was sometimes hard to remember that this was all happening because Jeffrey and I, over breakfast at Las Manitas in Austin, decided to take a chance and put on a show.  In a way, I had to prod myself just a little to remember to feel pride in what we’d accomplished.

What required no effort to feel was a deep sense of humility and awe that so many people had come to support what we did.  Over five hundred folks gathered in Boston, drawn by the same love of the web and pride in Doing Things Right that drives us.  I see the attendees at AEA as the craftsmen and women of the web.  Sure, there are shops mass-producing sites, the way a factory churns out cheap clocks.  That’s fine if you just want something to put on your nightstand.  But if you want an elegant, finely tuned work of art that you’d hang in a prominent place, a clock that is as much a point of pride as a timepiece—you find a craftsman.  And that’s who came to Boston.  That’s who comes to An Event Apart.

What amazed me even more was the overwhelming wave of positive feedback that we got.  Marci, our event manager, told me that in 25 years of event planning, she’s never seen attendees so happy.  So many people came up to me and Jeffrey and Marci just to say, “Thank you so much for doing this”.  They were thanking us, which seems entirely backwards.  I did thank each of them for coming to the event, but let me state it here for anyone I didn’t get to thank in person.  Thank you so much for coming to AEA and showing that you know creating the web is much more than churning out code, and that you take pride in being a craftsman.  Thank you for making the show so amazing.  Without you, it couldn’t have happened at all.

Now I’m looking forward to AEA Seattle twice as much as before, and I thought I was already maxed out on anticipation.

Again: wow.  Thank you, one and all.


AEA Seattle 2007 Now Open

Published 18 years, 2 months past
Limited seating is now available for An Event Apart Seattle 2007, June 21-22, at Bell Harbor International Conference Center on breathtaking Puget Sound. Spend two days with leading designers, developers, and accessibility experts including (in alphabetical order)…
  • Tim Bray, father of XML, director of web technologies at Sun Microsystems, and Tim Berners-Lee W3C appointee;
  • Andy Budd, user experience lead at Clearleft, co-founder of d.Construct, and author of CSS Mastery: Advanced Web Standards Solutions;
  • Mike Davidson, founder and CEO of Newsvine, former art director and manager of media product development for ESPN and the Walt Disney Internet Group;
  • Shawn Henry, director of education outreach for W3C Web Accessibility Initiative (WAI), research appointee at the MIT Computer Science and Artificial Intelligence Laboratory, and author of Just Ask: Integrating Accessibility Throughout Design;
  • Shaun Inman, award-winning designer and developer, inventor of Inman Flash Replacement and the curiously successful stats package Mint;
  • Jeffrey Veen, designer manager at Google, founding partner of Adaptive Path, and W3C invited expert on CSS before most of us knew the acronym;
  • Khoi Vinh, design director at NYTimes.com, author of Subtraction.com, and former partner at Behavior LLC;
…plus Jason Santa Maria, Eric Meyer, and Jeffrey Zeldman. A complete schedule is available for your perusal. The two days of design, code, and best practices, including lunch on both days and parties on both nights, go for $795 (reg. $895) if you register by May 21, 2007. An Event Apart Seattle 2007 will be our only show in the northwest this year. Seating is limited to 300 attendees and will sell out fast—they’re already going like hot cakes—so nudge that bean counter and come join us!

AEA Boston Full Up

Published 18 years, 2 months past

I’m sorry to be the bearer of bad news to any potential AEA Boston attendees, but we sold the last available seat just before noon yesterday.  You can still get in touch to request a spot on our waiting list. if you like.  If not, there’s always the Seattle show coming in June, with tentative plans for two more shows by the end of 2007.

Some of you may recall that I prophesied, a few weeks back, that we’d sell out on February 28th—and so we did.  Go me.  I feel like a regular Edgar Cayce.


Browse the Archive

Earlier Entries

Later Entries