Posts in the CSS Category

When Printing Maims

Published 19 years, 2 months past

Okay, ALA fans, we’ve deployed a print style sheet on the articles.  I don’t know if I could call it done, but it’s a big step.  Why wasn’t it online sooner?  Say it with me: “browser bugs”.  Just when the convergence of screen CSS handling had me feeling good, I had to go and mess with print styling.  Good feeling’s gone.

At the moment, the print styles seem to work quite well in modern browsers except for Firefox 1.0.6 (which is what I have in OS X).  There, when I call up a print preview, any article is fine until page 4.  Then things go off the rails in short order.  Content disappears, margins go wild, all kinds of fun stuff.  Here, try previewing or printing Nick Usborne’s “Helping Your Visitors: a State of Mind.  Now try it with J. David Eisenberg’s “Validating a Custom DTD” or (somewhat ironically) Ross Howard’s “High-Resolution Image Printing“.  Pages 1-3 are fine for me, but after that, no good.  When you get a nice long article like Joe Clark’s “Facts and Opinion About PDF Accessibility” or (completely ironically) my own “Going To Print“, you’re just asking for trouble.

I tried searching Bugzilla for some report, but my skills over there are not what once they were.  So while I got a bunch of results, I don’t know if any of them described this problem.  Could some kind soul let me know if there is a report on this sort of thing already?  If not, I can submit the report.  I just don’t want to add yet another DUPLICATE to the database.

And hey, if you can work out a solution to the problem, I have a factory-fresh ALA T-shirt all ready to send out—you even get to choose which one you want.  Let me know.

Update: Dan Wilkinson is our winnah!


An Event Apart Debuts

Published 19 years, 2 months past

I couldn’t be more proud to announce the launch of An Event Apart.  What is An Event Apart (AEA)?  It’s an all-day seminar, one that moves from city to city, featuring me and Jeffrey Zeldman.  The inaugural event will be held at the Franklin Institute in central Philadelphia, Pennsylvania on Monday, 5 December 2005.  We’ll be taking it to other cities in 2006; keep an eye on the AEA RSS feed for announcements.

Honestly, AEA can be summarized in one sentence: it’s the kind of seminar Jeffrey and I would want to attend.  Hopefully that right there is enough to get you interested, but wait until you hear the details.

  • No “intro to X” sessions.  We’re packing the day with as much detail, technical insight, and expert information as possible.  We won’t be taking any time to explain the basics of CSS or XHTML or anything else.  From the first minute to the last, we’re putting the pedal to the metal.
  • An intimate look at how Jeffrey and I do what we do.  Most of our material will be drawn from recent projects we’ve done together, such as the web sites for A List Apart, An Event Apart, UNIFEM, and others.  All the nifty tricks, browser hacks, practical compromises and development surprises—they’ll be laid bare for attendees to examine, question, chuckle over, and take back to their own work.
  • Going from  comp to complete.  How does one get from a visual comp file to a working XHTML+CSS page?  You’ll find out how we do it as we step through that very process.
  • Constant interaction.  This isn’t a rigidly formalized “we talk for 80 minutes and you ask questions for 10 minutes” kind of setup.  Jeffrey and I see it as more of a conversation between us and the attendees.  We’ll probably do most of the talking, and we’ll certainly have all kinds of stuff to talk about, but we’re really looking forward to questions that will take things in a new direction.  We want the attendees to ask tough questions about what we’re showing, and ask us about the tough problems they’ve faced.
  • Attendee markover.  For one of the day’s sessions, we’ll take a site submitted by an attendee and give it a markover, turning it into semantic XHTML and CSS without disrupting the visual appearance.  This will make for a great look at practical standards-oriented design for a real-world site.
  • Interesting venues.  Jeffrey and I been to a zillion conferences in hotel ballrooms and conference centers, and frankly we’re bored to death with that whole repetitive scene.  So we’re going to aim for places that are a little off the beaten path; venues that have some interest.  As an example, just look at the venue for AEA Philadelphia, the Franklin Institute; it’s one of the most prestigious science museums in the country.

The content of AEA won’t be just markup and CSS, either.  We’re going to talk about how standards-based design speeds up the development process, how we work in a distributed team, and how we approach web design in general.  We’ll share what’s worked for us and what hasn’t, and find out what experiences the attendees have had.

So if you’re in the Philadelphia area, or can reach it fairly easily, I strongly encourage you to take a look at the AEA site—and then ask yourself whether this is an event you can afford to miss.


The Constants Gardener

Published 19 years, 2 months past

This news is a little musty, but Shaun Inman updated CSS-SSC recently.  If you’re using CSS-SSC, you should definitely go grab the update.

“Hey, what’s CSS-SSC?” you exclaim?  Oh, I’m sorry.  It stands for Cascading Style Sheets Server-Side Constants.  Here’s Shaun’s initial example:

@server constants {
    linkColor: #AB6666;
    linkColorHover: #710101;
    }
a { color: linkColor; }
a:hover { color: linkColorHover; }

In other words, you can define your own constants in CSS.  This works because CSS-SSC is a preprocessor—it processes the style sheet before it’s sent to the browser, and turns it into something the browser can handle.  (Put another way, what arrives at the browser is a regular style sheet, with none of the ‘SSC’ information.)  Shaun offers more details in an earlier post.  CSS-SSC requires you to have PHP hanging about, and also to edit some stuff on your server, like .htaccess files.  You’ll also have to be careful about how you name your constants: use the constant name color, for example, and your CSS is going to go to a particularly mangled form of textual hell.

Personally, I’m both enthused and annoyed by CSS-SSC.  I think it’s a great solution: definitely one of the best, lightest-weight, easiest approaches to adding preprocessing to CSS.  I’m seriously considering putting it to use on ALA, in which I jumped through a few grouping hoops in order to get the fonts and colors just the way Jason wanted them.  Dropping back to constants would make life a bit easier—and would also simplify the whole “per-issue coloration” feature.  (Which I already have working, but via a large number of hoops, several of them on fire.)

I’m annoyed because it bothers me that Shaun had to create CSS-SSC in the first place.  There have been occasional requests for constants in CSS.  They get shot down every time.  “Use a preprocessor!” is the cry, and at first glance, CSS-SSC would seem to give credence to that response.  From my point of view, however, CSS should have had constants long ago, and what Shaun has done is proof.

The refusal to add constants as a feature of CSS has always stuck me as highly pointless.  Over the past decade, many people have expressed a need for CSS constants in a number of fora, and it’s a good bet many more have had the need without publicly expressing it.  Adding it to CSS would have done little to increase complexity on the implementor’s side; Shaun’s one-page PHP script (a good deal less when you remove the comments) proves that.  Adding it to CSS would have meant authors could just do it, without having to install anything else first.  Shaun’s made installation about as easy as it gets, but it’s still three or four steps more than should exist—and, for some authors, three or four impossible steps, due to their hosting situation.  And if you aren’t running a local web server, then you can’t test your CSS-SSC-enhanced styles locally; they’ll have to go to a web server first.

Because CSS still lacks, and will apparently continue to lack, a way to define your own constants, I’m really glad Shaun has devised this low-threshold solution.  I just wish that it hadn’t been necessary for him to do so in the first place.


Reserved ID Values?

Published 19 years, 2 months past

As a followup to my entry about id="tags" causing problems in IE/Win, here are four five test pages for IE/Win:

These are based on Kevin Hamilton’s observation that it’s highly likely the problems are caused by the tags method in IE/Win’s document.all DOM interface.  As he says:

[I]f you have an element with an id=”tags”, then document.all.tags is now a reference to that element, and no longer a method of the document.all object.

Such states would completely shatter any IE DOM scripting that relied on the document.all methods, and at least in the case of tags causes problems like crashing on print (probably because of the aforementioned conflict between the ID value and the DOM method).  The other keywords of concern are chronicled in the test pages listed above.  I’d test IE/Win myself, except I don’t have a printer handy for IE/Win to use, and besides, bug-hunting is best conducted in large groups.

Basically, load up each test page in IE/Win and do anything you can think to do.  Try to print, view source, save a local copy, et cetera, et cetera—the more obscure and offbeat, the better.  Let us know via the comments any problems you run into with said pages (trying to print them is a good first step, since that’s what messed up on tags) and I’ll add notes to each page based on what’s found.

In the meantime, I’m personally going to avoid using any of those words as ID values, and heartily recommend the same to you.

Update: I’ve added a test (for length) to the above list, and have another that’s not on the list due to its unfinished nature.  It’s a test of id="all"; the problem is, I don’t really know how to test it, or if it’s likely to be a problem at all.  Suggestions are welcomed in the comments.  I added some JavaScript links to some of the test pages as a secondary test, but I’m not sure how much good they do, to be honest.  As with suggestions, your feedback is welcome.

For those in search of more background, or trying to find new ways to test possible conflicts, or whatever, feel free to look over Microsoft’s documentation of the “all Collection”.


Workshopping in Chicago

Published 19 years, 3 months past

Remember how, back in July, I ventured across the Atlantic to give two full-day workshops on XHTML and CSS in London?  Well, this November the workshop is crossing the ocean: announcing “Professional CSS XHTML Techniques” this coming November 3rd in Chicago, Illinois.

Ryan Carson, one of the two founders of BD4D, is putting together a heck of a workshop series, as you can see by visiting the Carson Workshops home page.  There you’ll find my workshop listed, as well as seminars from Cal Henderson, Joe Clark, and Molly Holzschlag and Andy Clarke.  So far, they’re all headed to London, but given the past history of Ryan’s efforts, I think it’s a good bet some or all of them will be headed Stateside in the future.

As in London, your registration gets you a copy of the “XHTML / CSS Survival Kit”, a disc containing all kinds of examples, articles, tools, and so forth.  You’ll also get a whole day of high-tempo, practical instruction in CSS-driven design, with plenty of opportunity to pose questions and get answers.  I had a great time in London, and the attendees seemed to have just as good a time.  I’ll be doing an updated version of what I did there, so if you wanted to attend the London event but couldn’t swing the transoceanic airfare—well, here’s your chance to make up for it!

Addendum: you know, I was so excited to tell you that the workshop was going to happen that I completely neglected to mention that registration is already open!  So get yerself on over to the Carson Workshops site, click on through to my seminar, and sign up already!


Web Page, Mutated

Published 19 years, 4 months past

One of the first rules of life is that first-hand information is always better than second-hand information.  You can be more certain of something if you’ve seen it with your own eyes.  Anything else is hearsay, rumor, conjecture—an article of faith, if you will.  At the very minimum, you have to have faith that your source is reliable.  The problems begin when sources aren’t reliable.

No, this isn’t a rant about the intelligence screw-ups previous to the invasion of Iraq.  Instead, it’s a warning that inspector programs and saving as “Web page, complete” features can lead you astray.

One such example came up recently, shortly after I mentioned the launch of the new Technorati design.  A question came in:

I did want to ask about the use of -x-background-{x,y}-position as opposed to background-position. If I understand correctly, the -x prefix indicates an experimental CSS attribute, so in what circumstances should one use this sort of experimental attribute instead of an official one?

I’d have been glad to answer the question, if only I’d known what the heck he was talking about.  Those certainly weren’t properties I’d added to the style sheets.  They weren’t even properties I’d ever heard of, proprietary or otherwise.

Just to be sure, I loaded the CSS files found on the Technorati site into my browser and searched them for the reported properties.  No results.  I inquired as to where the reporter had seen them, and it turned out they were showing up in Firefox’s DOM Inspector.

Now, the DOM Inspector is an incredibly useful tool.  You can use it to look at the document tree after scripts have run and dynamically added content.  You can get the absolute (that is, root-relative) X and Y coordinates of the top left corner of every element, as well as its computed dimensions in pixels.  You can see the CSS rules that apply to a given element… not just the everyday CSS properties, but the stuff that the Gecko engine maintains internally.

That’s where the problem had come in.  The DOM Inspector was showing special property names, splitting the background-position values into two different pseudo-properties, and not showing the actual background-position declaration.  This, to me, is a flaw in the Inspector.  It should do two things differently:

  1. It should show the declaration found in the style sheet.  There should be a line that shows background-position and bottom left (or whatever), because that’s what the style sheet contains.
  2. It should present the internally-computed information differently than the stuff actually taken from the style sheet.  One possibility would be to show any internal property/value pair as gray italicized text.  I’d also like an option to suppress display of the internal information, so that all I see is what the style sheet contains.

The person who asked why I was using those properties wasn’t stupid.  He was just unaware that his tool was giving him a distorted picture of the style sheet’s contents.

Don’t think Firefox is the only culprit in unreliable reporting, though.  Anyone who uses Internet Explorer’s save as “Web page, complete” feature to create a local copy for testing purposes isn’t getting an actual copy.  Instead of receiving local mirrors of the files found on the Web server, they’re getting a dump from the browser’s internals.  So an external style sheet will actually be what the browser computed, not what the author wrote.  For example, this:

body {margin: 0; padding: 0;
  background: white url(bodybg.gif) 0 0 no-repeat; color: black;
  font: small Verdana, Arial, sans-serif;}

…becomes this:

BODY {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px;
BACKGROUND: url(bodybg.gif) white no-repeat 0px 0px;
PADDING-BOTTOM: 0px; MARGIN: 0px; FONT: small Verdana, Arial, sans-serif;
COLOR: black; PADDING-TOP: 0px
}

Okay, so it destroys the authoring style, but it isn’t like it actually breaks anything, right?  Wrong.  For some reason, despite IE treating the universal selector correctly, any rule that employs a universal selector will lose the universal selector when it’s saved as “Web page, complete”.  Thus, this:

#sidebar {margin: 0 74% 3em 35px; padding: 0;}
#sidebar * {margin: 0; padding: 0;}

…becomes this:

#sidebar {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px;
MARGIN: 0px 74% 3em 35px; PADDING-TOP: 0px
}
#sidebar  {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px;
MARGIN: 0px; PADDING-TOP: 0px
}

Oops.  Not only can this mean the local copy renders very differently as compared to the “live” version, it’s also very confusing for anyone who’s saved the page in order to learn from it.  Why in the world would anyone write two rules in a row with the same selector?  Answer: nobody would.  Your tool simply fooled you into thinking that someone did.

Incidentally, if you want to see the IE-mangled examples I showed in a real live set of files on your hard drive, go save as “Web page, complete” the home page of Complex Spiral Consulting using IE/Win.  And from now on, I’ll always put “Web page, complete” in quotes because it’s an inaccurate label.  It should really say that IE will save as “Web page, mutated”.

So if you’re Inspecting a page, or viewing a saved copy, remember this:  nothing beats seeing the original, actual source with your own eyes.  If you see something odd in your local copy, your first step should be to go to the original source and make sure the oddness is really there, and not an artifact of your tools.


Workshop Wrap-Up

Published 19 years, 5 months past

I think that, overall, the workshops went very well indeed.  Probably the most frustrating thing was that the hotel lacked net access for the entire time I was there.  Oh, they had a network, with drops in the rooms and a first-floor wifi cloud.  It’s just that the network was completely broken for the entire five days, save a two-hour window in the middle of one of the days.

But that annoyance aside, everything else was great.  The attendees asked a lot of interesting questions and soaked up the firehose of information I was blasting their way.  There was some good (and good-natured) give-and-take on the subject of tables versus CSS for layout, with plenty of examples of where each approach might be better or worse than others.  And hey, I wore a tie!  Both days!  Ryan has the picture to prove it!

He also has the British spelling of “favorite” to prove that he’s been away from Colorado for too long.

Anyway, I’d like to send a huge thank you to everyone who attended for making it a great experience.  I had fun, and I think you did too.  Now for two bits of trivia about the attendees:

  • The quiet, bearded man who sat house right in the third or fourth row on Saturday was none other than Michaël Guitton, a significant and early contributor to S5, the slide show system I used to present the morning notes.  I didn’t find this out until the end of the day, or else I’d have made him stand to take a bow.  (Which might be why he waited until the end of the day to introduce himself.)

    He was also the only person at lunch to order the salmon, although I came very close to doing so myself.

  • On Friday, as a number of us headed up the street for social hour, one of the attendees mentioned he’d been in Cleveland and Columbus many years ago.  I asked what had brought him there, and he said he’d been touring with a band.

    “Oh, really?” said I.  “That’s cool.  Um, any chance it’s a band I might have heard of?”

    “The Jesus and Mary Chain”, he said.

    WHAT?!?!?

    I had to ask him three times if he was having me on.  Turns out he wasn’t: I was talking to Dave Evans, who was their guitarist in the late 80s.  Seriously.  I could not make this up even if I tried.  I really had a former member of the Jesus and Mary Chain in my CSS workshop.

    That’s so far beyond incredible that I can’t even describe where it ends up.


Universal Child Replacement

Published 19 years, 5 months past

The other day I hit a situation that pushed me to come up with a way to simulate the child selector in a way Internet Explorer could understand using two rules.  I doubt I’m the first to think of it, but I’d never seen it before, so I thought I’d document the solution here.

The deal was that I had a column of text featuring white background with some black flecks in it.  On top of that went some near-black text.  All fine, except where the text sat on top of a fleck, which made it next to impossible to read.

To counteract that effect, I decided to set the background of the various descendants of that div to be white, so they’d mask any flecks they were overlapping.  Thus I wrote:

#main * {background: #FFF;}

It worked great for about a second.  That’s when I realized that I had links in the column, and some of them were sitting inside table rows with a non-white background.  The rule I’d just written was giving the links white backgrounds, which had the visual effect of punching holes in the row backgrounds.  That was no good.

What I really needed was a way to just set white background on elements that were children of #main.  CSS has a child selection combinator (>) but neither version of Internet Explorer supports it.  After a few moments’ thought, I realized that I could add a rule that would make transparent the background of any element that was at least a grandchild, but not a child, and it would still work in Explorer.

#main * {background: #FFF;}
#main * * {background: transparent;}

The end result is that there is a way to simulate child selection without actually using the child combinator.  The general pattern is to use a normal descendant selection in your first rule, and then “undo” the first rule with a second that has a universal selector in the middle.  Suppose you want to boldface any p element that’s a child of a div, but no others.  The solution:

div p {font-weight: bold;}
div * p {font-weight: normal;}

It might not be something you use every day, but if it’s needed, there you go.

Update: Lachlan points out that you’ll need to watch out for specificity conflicts when using this technique.


Browse the Archive

Earlier Entries

Later Entries