Posts in the CSS Category

CSS Sculptor Released

Published 17 years, 3 months past

I alluded yesterday to “backstage work”.  One of the things going on back there was my work with the folks at WebAssist to create a tool that allows both novice and experienced web developers to create and alter CSS-driven layouts.

The end result is Eric Meyer’s CSS Sculptor (v1.0.0), a Dreamweaver extension that gives the user tons of options and outputs pretty darned clean markup and CSS.  (Even if you’ve no interest at all in Dreamweaver tools, you should still follow that link.  How many chances are you going to have to see me throw the mëtäl hörns?)

Well you might wonder how much code I contributed to this software.  Well, okay, none.  What I did contribute was guidance on the interface and its organization; on what options to present, and how; on ways to handle things like print styles and the print CSS options; and on the CSS and markup that results, including the optional explanatory comments in the CSS.

One of the primary goals with this project was to create a tool that would expose as much CSS as possible to users without overwhelming them, and that would actually teach by dint of showing all the options.  One of the things we heard a lot in the beta test was users saying things like, “Oh, so that’s what that CSS thingy does! I’d always wondered.”  Which was exactly what we’d hoped to hear, along with “Hey, I’ve never heard of this CSS property before!”.  (We heard that one too.)

There are some things I expect will be improved in future releases, like shorthand value minimization—the simplest example of that being a condensation of 0 0 0 0 down to just plain 0.  We discussed including that feature but decided to postpone it for a variety of reasons, not least of which was working out the logic required to figure out when to minimize, which isn’t as simple a problem as you might first think.  There were a few other things we didn’t get in the initial release; such is the way of software.  We’ve got a list of potential features, of course, and are looking forward to hearing what users suggest.

As for what features did make it in, there’s a fairly large list, so it’s probably best to check out the Features page or take the product tour—with video commentary starring, you guessed it, yours truly.  So if you’ve ever wanted to see me greenscreened over screenshots and being intermittently goofy, then at long last your prayers have been answered!  (Or will be, once we get the load problems resolved.)

What makes this whole thing an especially interesting experience for me is that, for the first time in my life, I’m participating in an affiliate program.  Basically, what I earn from sales of CSS Sculptor depends on affiliate fees earned by referral links like this one here (and also earlier in the post).  That might sound like a rip-off, but it has the potential to be quite the opposite.  The affiliate cut is literally an order of magnitude greater than any reasonable per-unit royalty would be.

This compensation scheme (as they say in the UK) is actually an experiment on both sides: WebAssist has never really worked with an outside individual on a product like this, and so they honestly don’t know if the affiliate approach will pay better than a per-unit royalty, or worse.  So we’re going to try it out and see what happens.  Fortunately, I’m in a position that I feel I can afford to experiment like this, allowing both myself and WebAssist to find out what works best in the long run.

Thus, if you’re planning to buy CSS Sculptor or know someone who is, I’d be grateful if you either clicked through one of the links hereabouts or linked to the product using my affiliate URL.  I’ll have a link in the sidebar in the near future as well.  The sidebar’s due for an overhaul anyhow.

So that’s one of the things that’s claimed my time over the last few months, and I’m pretty excited that it’s seeing the light of release.  I’m even more excited about finding out what people think could be better about it so that we can improve what’s already a pretty darned nifty tool.  If I do say so myself.


Running on :empty

Published 17 years, 3 months past

While kicking around some ideas at the CSS workshop I led in London, I ran into some interesting problems with :empty.  If you’re not up on what that one does, it’s a way of selecting elements that have no children, including text.  To quote the formal definition:

The :empty pseudo-class represents an element that has no children at all. In terms of the DOM, only element nodes and text nodes (including CDATA nodes and entity references) whose data has a non-zero length must be considered as affecting emptiness; comments, PIs, and other nodes must not affect whether an element is considered empty or not.

So kindly consider:

*:empty {
   padding: 0.25em;
   outline: 1px dashed red;
   background: yellow;
}

We (re)discovered something very strange right there in the workshop: given the preceding rule, Firefox applies it to the body element—which is, quite clearly, not empty.  You can check out the fun on my bare *:empty test page.  From there, we realized that if you prepend a body to the selector, yielding body *:empty, the problem vanishes, as you might expect.

As it turns out, this is a known bug in Gecko.  It’s been known for about 18 months, in fact.  So that’s why I was confused by Firefox’s behavior.

The other problem is that :empty in Firefox matches img elements, whether or not they cause an image to successfully load.  You can see this happen on the same test page.  While it’s true that img is an empty element, it’s still bringing in content, so from a common-sense point of view it seems that :empty ought not to match.

In re-reading the description from the specification, though, I can’t justify my common-sense interpretation—an img element has neither element nodes nor text nodes, so far as I’m aware.  The same is true for form inputs, even text inputs that have pre-filled value text; but not for textareas that have pre-filled content text.  But then br elements should also be selected by this rule, and they apparently don’t get matched at all, as the test page shows.  Bwuh?

Well, maybe it’s a bug.  What concerns me here is that the definition of :empty basically requires that things like images and inputs always be selected, which strikes me as kind of useless.  After all, if I wanted to select all images, I’d write img into my selector; ditto input for inputs.

My thinking is that the description should change to state that application of :empty is restricted to non-replaced elements.  Alternatively, it could be redefined to only apply non-replaced elements and to empty replaced elements that don’t either cause something to load or have values associated with them.

Which seems a better solution to you, and why?  Or, if you see a better approach than either of those, what is it?


London Workshop

Published 17 years, 4 months past

So while I was off indulging in the extravagance of an extended vacation/family reunion/road trip, seats went on sale for a two-day CSS workshop in London, starring yours truly and run by the fine folks at Carson Workshops, which will run 13-14 August.  The seats are something like half-sold already, so if you want in, don’t wait.  Sorry I didn’t say anything sooner, but, you know.  Family time!

To those who do decide to attend, I make this pledge: I will not wear the blue-shirt-with-tan-slacks combo again.  This I swear.


Who Ordered the Link States?

Published 17 years, 5 months past

Thanks to everyone who shared their thinking on the ordering of link states.  It looks like a minority of people were in favor of my preferred ordering, which is: Link-Visited-Hover-Focus-Active.

The reasoning is fairly straightforward, and starts with the assumption that a person who uses solely a keyboard to navigate won’t ever encounter a hover effect.  Thus, for such users, the states might as well simply be LVFA.  For them, the placement of the hover styles is irrelevant.

On the flip side, a person using a mouse to navigate will have far more links in hover states than focus states.  Once a link is selected (clicked) by a mouse-wielder, the link enters the active state until the user lets go of the mouse button.  Then it’s both in focus and hovered, at least until the mouse cursor moves away.  (It’s also either visited or unvisited, but that’s not relevant to the question at hand.)

So in this situation, I want to provide a visual cue that the link has in fact been clicked, even though the mouse button is no longer down.  I want this to happen regardless of the hover states of the link.  Therefore, the focus styles need to come after the hover styles.  If not, the focus color will only take effect once the mouse moves away from the link, thus exiting the hover state and removing the hover color.

Yes, this will only take hold in browsers that update the focus state while asking for the requested page.  While that isn’t all browsers, it’s most of them, from what I can tell.  Safari 2.x seems to be the notable exception.  (I didn’t test 1.x, and haven’t installed 3.x yet because I don’t want to lose 2.x.)

So what mnemonics can we use to keep this ordering straight?  I’ve come up with a few.

  • LoVe’s Hurts Fade Away
  • Luther Vandross Hits Fabulous Arpeggios
  • Lord Vader Hates Furry Animals
  • Lusty Vampires Hunger For Absinthe
  • Lord Voldemort Has Foul Ambitions

What do you have?


Ordering the Link States

Published 17 years, 5 months past

Spend any time at all writing above-beginner CSS, and you’re going to come across the “link-visited-hover-active” (LVHA) rule.  This holds that the four link states should always be listed in that order, like so:

a:link {color: blue;}
a:visited {color: purple;}
a:hover {color: red;}
a:active {color: yellow;}

Masters of the dark arts of specificity know why this rule exists and how it does or doesn’t apply, but if you’re still a padawan in these matters (or just rusty), you can get a quick refresher from this old chestnut of mine.

Now, it’s the case that this will become less of an issue over time becuase IE7 supports (and one presumes future versions of IE will continue to support) chained pseudo-classes, like a:link:hover {color: red;}.  Once you start chaining those you transcend a lot of the specificity-ordering concerns that drive the LVHA rule.  However, we’re not there yet.

Which brings me to the point of all this: the fifth possible link state, :focus.  Assuming we’re going to avoid chaining pseudo-classes for a while yet, but that we want to introduce link-focus styles, where should it fit in the ordering?  For the purposes of this discussion, assume the following:

a:focus {color: orange;}

a:link {color: blue;}
a:visited {color: purple;}
a:hover {color: red;}
a:active {color: yellow;}

We need to move the a:focus rule so it has a visible effect.  But where?  Should it come before a:hover, after a:hover, or after a:active?  In other words, which states’ styles should the focus style overwrite?

I’d like to hear your thoughts on the matter, and especially the rationale driving your answer.  Accessibility experts are particularly welcome to weigh in, but it’s anyone’s game here.

(Postscript: I know that many problems can be avoided by picking a different styling effect for the focus style, like a border or outline, or boldfacing or italicizing the text of a focused link.  Still, some people will want to handle everything through color, regardless of the problems this can cause for the colorblind or images-as-links, and I’d like to address that specific situation.  Thanks.)


Formal Weirdness

Published 17 years, 6 months past

As I described and tweaked my version of reset styling, a fair number of people asked (with varying degrees of politeness) why I didn’t just use a universal selector instead of that big ugly grouped selector.  I said that I wanted to avoid styling form controls (inputs, textareas, and so on), and the only way to do that, given the state of selector support in today’s browsers, is to list all the elements I want to reset while leaving out those I don’t want to touch—like all the form controls.

This led to a fair number of questions as to why I’d bother avoiding form controls, and I said it was due to their “inherent weirdness”.  By this, I meant that form controls are impossible to describe with current CSS; and if they were treated the way CSS says they should be, we’d all hate the results.  Furthermore, the handling of form control styling is going to be a very unstable branch of our field for the foreseeable future.

Herein, I scratch the surface of this entire mess.  Fair warning up front: this is going to be a long one.  Also, as Bette Davis once proclaimed, buckle your seat belts: it’s going to be a bumpy ride.


Let’s start with a (seemingly) simple form element: a checkbox.  Here are two in Firefox, one checked and one unchecked.

All right, now here’s a question: what should happen if I assign these checkboxes padding: 10px;?  Take a moment and think through the details.

“That’s an easy one,” you may say.  “There’s 10 pixels of padding between the checkmark and the borders of the box.”  And maybe you’re right.  But let’s consider the same question for these checkboxes from Safari.

Notice how the checkmark hangs jauntily out of the box?  If we add padding, does the checkmark become contained within the box—in other words, does the checkmark stay the same size while the box visually expands—or does it stretch in size so that it’s still sticking out of the box?  You don’t even have to think about what to do with the drop shadow or the glassy beveled highlight effect; just worry about what to do with the checkmark.  Again, take a few moments to think through all the implications.

All right, you should have an answer by now.  Bully!  The sad truth is that no matter what you’ve decided, you’re wrong.  Okay, I admit that’s unnecessarily harsh:  more properly, you aren’t right.  You can’t be, because there are no defined answers to these questions.

Thus, if a browser lets you style a form element, it’s doing so blindly, from a specification-compliance point of view.  The people who wrote that browser code were guessing.  No doubt they were intelligent guesses, but they’re guesses all the same.

So why not just define the answers?  That turns out to be a good deal trickier than we might hope.  Take checkboxes (please!).  They’re replaced elements, right?  You have an input element that ends up placing a symbol, in much the same way an img element places an image file.  The symbol changes based on whether the checkbox has been checked or not, something like a JavaScript-driven image-swap.  The appearance of the checkbox isn’t defined in any way, so browsers are free to do whatever they want, as we saw above.

That means that the “interior” of this kind of input element—the checkbox (filled or not)—is a black box from a CSS point of view.  There’s nothing in the document structure or content that represents the actual checkmark, for example.  You can’t in good conscience define the checkmark as content and the checkbox as the element that surrounds it.  So should padding apply at all?  Maybe.

But if it does, and the checkbox is a replaced element, then defining a background color and padding for the checkbox would put the defined background color around the symbol—the whole symbol, checkmark and checkbox and all—instead of inside the checkbox.  That’s a completely reasonable conclusion given the assumption that the checkbox symbol is replaced.  It’s just completely unreasonable if you’re a visual type and you want that checkbox to be filled in with red, for the love of Bob!

So: is a checkbox a combination of an element box surrounding content, or a completely replaced element?  Which padding-and-background effect should take hold?

Just to muddy the waters a bit further, consider the following:

  • What happens to the checkmark when the input is italicized, either directly or by inheritance?  How about when it’s boldfaced?  (Assume the checkmark comes from a font family that has italic and boldfaced versions of the checkmark available.)  What, if anything, should happen to the checkbox under either condition?
  • If text-decoration: underline is applied to the checkbox, should the whole box be underlined, or just the checkmark?  Does your answer change when you consider the effects of padding?
  • Should vertical-align apply to the checkmark, or to the checkbox as a whole in relation to the line of text in which it sits?
  • What effect should line-height have on the checkbox and its contents?  For example, what should happen if you say input[type="checkbox"] {line-height: 3em;}?  Don’t forget that the most common way for an element to experience altered line height is by inheritance.
  • Should height and width be honored on a checkbox?  If so, should they apply to the whole box, or to the “content” (the checkmark)?  If the former, what should happen to the checkmark as a result–should it stay the same size and be aligned in some way, or should its size scale along with the checkbox?

In my experience, the most common answers to these questions tend to be contradictory—some implying a box-and-content model, others implying a replaced model.  I mean, just look at the poser buried in the middle of that last point.  What does width even mean when it comes to a form control?  Is it just the content, like with non-replaced elements; or is it the whole element box, borders and all, like in replaced elements?

As far as the latest draft of CSS 2.1 is concerned, all inputs (really, all form controls) are replaced, the same as images.  So no background inside the checkbox; no change due to italics or boldfacing or line heights; vertical-align shifting the box as a whole; and height and width applying to the entire box.

You might feel that’s acceptable, overall, but remember that I said CSS 2.1 regards all form controls as replaced.  So all that would be just as true for text inputs and textareas as it is for checkboxes.  That’s probably not acceptable to most people.  For example, that would mean that vertical-align: baseline would put a text input’s bottom edge on the baseline of the text that surrounds it, instead of aligning the text inside the input with the text around it.  Almost everyone prefers the second to the first, and most browsers conform to that preference, but that’s not what should happen.  In fact, when it comes to form controls, nearly all known browsers ignore the specification’s assertion that form controls are replaced elements.

And we haven’t even touched the hard cases, like select boxes.  Here’s one from Firefox in the “closed” and “open” states.

Let’s jump straight to the obvious puzzler: what should happen if you declare select {padding: 10px;}?  Here are three different possibilities for just the closed select.

Go ahead, pick your favorite.  Got it?  Now, should the same thing happen when the select is “open”, showing all the options?  For that matter, should the same thing happen given this select box from Safari?

It does no good to say that your choice would be just fine if Safari would only just go along with everyone else.  There is no pre-defined appearance for select boxes, or for any other form control.  In Safari’s case, it’s pulling these things right out of OS X and placing them in the document—the very definition of replaced-element behavior.  (And yet, browsers keep treating them as if they’re non-replaced.)  Explorer does the same thing, actually, and is the reason why form controls seemed to have infinite z-index in IE6 and earlier—they were drawn by the OS after everything else on the document had been laid out.  Firefox, on the other hand, draws its own form controls, which is why they’re more consistent across operating systems, but also don’t suffer from draw-order issues like Explorer did.  (It’s also part of the reason Firefox takes longer to launch on many systems; rather than making use of the OS for things like form controls, it has to carry its own around with it.)

We could get into a very long discussion about whether form elements should always reflect the operating system or not, which usually breaks down to HCI advocates on one side of the debate and designers on the other.  Let’s not, though (at least not here).  Let’s just assume that form controls should be styleable, because that brings us right back to the central dilemma: how, exactly?

After all, we can make the previous select box riddle even more interesting.  Suppose you declare this:

select {padding: 10px;}
option {padding: 10px;}

Now what?  After all, there’s an option element visible there in the select box from the moment it’s drawn—or is it?  Maybe that’s a special feature of a select element that copies content from an option element to display when no option elements are visible.  We don’t know.  But let’s assume that what we see there is an option element visible inside the select element.  It’ll be either the first one in the list, or the one with a proper selected attribute.  Hey, what about this rule set?

select {padding: 10px;}
option {padding: 10px; border-bottom: 1px solid gray;}
option[selected] {font-style: italic; background: yellow;}

Yee haw!  There are a ton of questions I could pose here, but I’ll go with one of the trickier ones: should the gray option bottom border be visible inside the select box when the select is “closed”, or should it only appear on option elements when the select is “open”?  Oh, and here’s another good one: does the padding on the select element apply to the drop-down menu made up of option elements, or no?

The beauty is that whichever answers are perfectly obvious to you, it’s perfectly obvious to someone else that your answers are completely wrong.  And vice versa.

And remember, these are some of the simpler cases.  When you start considering things like how to style radio buttons and file inputs, things get really hairy.  I mean, just look at the differences between Safari and Firefox.

Merely sticking to questions of padding and background colors is vexing enough.  Start throwing in text/font styling, borders, and even foreground colors; they quickly generate a cornucopia of complex control condundra.  The pain!

And don’t think the entire issue of styling form controls is going to get any easier; in fact, the Safari team is about to make it a good deal harder.  If you read their post “Text Fields“, you’ll see that Safari will soon make it possible to do all kinds of stuff to text inputs.  (If you’re downloading nightly builds of Safari, it already allows these.)  Of the nine example images, only two have any hope of being described using current CSS—and even those have to dodge questions like exactly how a text input should be baseline-aligned (as mentioned earlier).

So in order to style form controls in any sort of meaningful way, it will be necessary to invent a whole bunch of new properties and pseudo-classes (and most likely pseudo-elements) and describe how they behave and interact.  That’s much more easily said than done.  It’s taken more than five years to not finish CSS 2.1, and that’s just a reduced and clarified version of CSS 2.  Just imagine how much longer it could take to not finish inventing a whole new branch of CSS.

Not that anyone’s really working on it right now.  The closest we have is the Basic User Interface Module, which became a Candidate Recommendation on 11 May 2004 (yes, three years ago) and has not moved since.  There is no other form controls module.  There are things that could apply in a variety of other modules (like “The box model“, “Generated and replaced elements“, and “line“), but none of them are explicitly about form controls and so their relevance is at best debatable.

In that vacuum, browsers are acting to different degrees.  As we saw earlier, Safari is pushing forward in a major way.  Explorer allows some form control styling, but not much.  Firefox allows a little more—but not all that long ago, it ignored all attempts to style form controls.  Opera blocks attempts at form styling, the last I checked.

Because there are no agreed answers, and each browser is making its own guesses, there are inevitably going to be conflicts.  If one out of five browsers uses (for example) padding to set the separation between the content and borders of text inputs, then * {padding: 0;} is going to make them seriously scrunchy, while the other four will completely ignore it.  I might then declare input[type="text"] {padding: 2px;}, but what happens when one of the other four starts applying styles to form controls, but treats padding on text inputs differently, adding padding to the default form control layout because it treats the whole interior of the input, instead of just the text, as the content?


As veterans of meyerweb have already guessed, this is not a post with answers.  Like many of my longer entries, it poses only questions and (I hope) provokes thought.  What I hope it also does is explain my aversion to applying CSS to form controls, and thus why I constructed a great big grouped selector for my reset style sheet instead of using the universal selector.  I understand why so many people want to go the universal route: it’s a lot simpler to type and uses a lot fewer characters.  I’m usually one for saving characters, but this is one case where I think extra characters are more than worth the possible cost.


Reset Reloaded

Published 17 years, 6 months past

After a bit of time to bake and a few more suggestions from readers, I have what I’m willing to call the final version of my take on the topic of reset styles.  To wit:

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,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
	margin: 0;
	padding: 0;
	border: 0;
	outline: 0;
	font-weight: inherit;
	font-style: inherit;
	font-size: 100%;
	font-family: inherit;
	vertical-align: baseline;
}
/* remember to define focus styles! */
:focus {
	outline: 0;
}
body {
	line-height: 1;
	color: black;
	background: white;
}
ol, ul {
	list-style: none;
}
/* tables still need 'cellspacing="0"' in the markup */
table {
	border-collapse: separate;
	border-spacing: 0;
}
caption, th, td {
	text-align: left;
	font-weight: normal;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: "";
}
blockquote, q {
	quotes: "" "";
}

So what changed from the last iteration?

  1. I added background: transparent; to the first rule.  It’s probably not as necessary as some of the other bits here, but it seemed like a good thing to add.

  2. Added a :focus rule to try to suppress link outlining.  Why?  So that you remember to define your own.  You should make sure to define an outline, as it’s an important accessibility aid.  If you have a universal default, one that applies no matter what the project, then replace my rule with your own.

  3. There’s now a body rule that sets a baseline line-height that will be inherited by the rest of the document (and can be overridden easily), and sets a foreground and background color.  Originally, I avoided setting the colors, but decided it was better to put them in.  Of course, if you have preferred color defaults other than black on white, edit the declarations to suit your taste.

  4. The a img, :link img, :visited img rule has been dropped.  This is because the only browser family it really affects is Gecko line, and they all honor author styles as having precedent over user agent styles (as they should!).  So this is already covered by the first rule.

  5. Added a rule for caption, th, td to be left-aligned and normal-weight.

  6. Added a blockquote, q rule to suppress quotes by way of the quotes property.  This has the same intent as the previous rule, but approaches it along a different route.

I also asked for help in figuring out how to simulate inherit in IE/Win.  In the end, it seems to me like doing so isn’t really necessary for most people.  As I said before:

[The inherit] 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.

So that works for me, and I think for most people who have outlooks similar to mine.  But maybe you develop primarily in IE/Win, or you really want to have IE/Win handle as many of these resets as humanly possible.  In that case, you have two basic choices.

  1. Use the script and syntax contributed by Jonathan Snook and Dean Edwards.  Note, however, that Dean himself doesn’t recommend doing this, feeling that it’s too computationally expensive for such a small effect.  Dean has a lot of experience with scripting around IE/Win’s limitations, so I give his views on this a lot of weight.  On the other hand, I’d like to see IE/Win be able to honor inherit, or at least get the same behavior, so I might still use the script.  (Though I’d be even happier with a script that just tacked itself onto instance of inherit in a style sheet, like Dean’s IE7 script does for other CSS stuff.)

  2. Put in your own expressions, along the lines suggested by Priit and thacker.  It’s not quite the same thing, but it’s a pretty decent approximation.

Like I say, these aren’t necessary unless you’re really sold on the idea of IE/Win being forced into line with everyone else and don’t mind paying the computational overhead.  If so, then you can extend your own reset styles as needed.

That’s much of the point here: that this is not a case of “everyone must use these styles in a certain way without alteration”.  Nor am I saying that everyone must use them or else be cast into darkness.  Remember before that I termed these “my take on the topic of reset styles” (emphasis added).  Your take may be subtly or greatly different.  Think of these as a starting point for creating your own defaults, in addition to being a way to illuminate the nature of browser defaults.  Simply the act of taking those defaults into consideration and thinking about them closely puts you ahead of 99% of your peers.  I do think that reset styles are quite useful; otherwise, I wouldn’t have written about them here, and certainly not to the extent that I have.  My hope is that people will use them as a launch pad for their own resets and for deeper thinking about styling and browsers.

My thanks to everyone who commented, not just those I linked above.  And yes, I’m going to get to that “weirdness of form elements” post in the near future.

Addendum 2 May 07: I edited the CSS to change background: transparent to background-image: transparent, as it was supposed to be from the outset but I somehow didn’t see in any of the three times I looked over the declarations.  So I guess that makes this post now “final.0.1”.

Addendum 4 May 07: background-image: transparent?  There’s a big ol’ WTF.  Apparently my cold medication has warped me a lot more than I believed.  I’ve taken out that whole declaration and will not be editing the styles any further until I’m off the meds.  So, not quite final, apparently.


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!


Browse the Archive

Earlier Entries

Later Entries