Posts Tagged ‘css’

hierarchies, taxonomies, categories, drill-downs, etc.

Wednesday, February 25th, 2009

I searched all over the place for a tidy pattern to deal with displaying hierarchical data for selection (as in a set of categories and sub-categories or a taxonomy), and couldn’t find anything. I think everyone’s aware of how this can be done with AJAX, but I wanted something that would still work without needing Javascript or a round-trip to the server each time a parent category changed. Obviously that means storing the entire taxonomy on the page, which is only realistic for some uses of this sort of control, but it’s those uses I’m interested in.

My solution is to load the entire taxonomy into an unordered list and include a radio button in each list item. This shows the hierarchy clearly and lets the user select a node of any depth (a requirement in my case). I use some Javascript to hide the radio buttons and show/hide child lists based on clicks on the list items themselves, then check the radio buttons behind the scenes. I’m wondering if this is the best possible solution for my circumstances. My hope is that neatly organizing the data in this way makes it more accessible, but I’m no accessibility expert.

The HTML itself is pretty simple (excuse the junk data):

<div id="taxonomy">
	<ul>
		<li><input type="radio" name="ghj" value="A" /> A
			<ul>
				<li><input type="radio" name="ghj" value="I" /> I
					<ul>
						<li><input type="radio" name="ghj" value="1" /> 1
							<ul>
								<li><input type="radio" name="ghj" value="a" /> a</li>
								<li><input type="radio" name="ghj" value="b" /> b</li>
								<li><input type="radio" name="ghj" value="c" /> c</li>
								<li><input type="radio" name="ghj" value="d" /> d</li>
								<li><input type="radio" name="ghj" value="e" /> e</li>
							</ul>
						</li>
						<li><input type="radio" name="ghj" value="2" /> 2</li>
						<li><input type="radio" name="ghj" value="3" /> 3</li>
						<li><input type="radio" name="ghj" value="4" /> 4</li>
						<li><input type="radio" name="ghj" value="5" /> 5</li>
					</ul>
				</li>
				<li><input type="radio" name="ghj" value="II" /> II</li>
				<li><input type="radio" name="ghj" value="III" /> III
					<ul>
						<li><input type="radio" name="ghj" value="6" /> 6
							<ul>
								<li><input type="radio" name="ghj" value="f" /> f</li>
								<li><input type="radio" name="ghj" value="g" /> g</li>
								<li><input type="radio" name="ghj" value="h" /> h</li>
								<li><input type="radio" name="ghj" value="i" /> i</li>
								<li><input type="radio" name="ghj" value="j" /> j</li>
							</ul>
						</li>
						<li><input type="radio" name="ghj" value="7" /> 7</li>
						<li><input type="radio" name="ghj" value="8" /> 8</li>
						<li><input type="radio" name="ghj" value="9" /> 9</li>
						<li><input type="radio" name="ghj" value="10" /> 10</li>
					</ul></li>
				<li><input type="radio" name="ghj" value="IV" /> IV</li>
				<li><input type="radio" name="ghj" value="V" /> V</li>
			</ul>
		</li>
		<li><input type="radio" name="ghj" value="B" /> B</li>
		<li><input type="radio" name="ghj" value="C" /> C</li>
		<li><input type="radio" name="ghj" value="D" /> D</li>
		<li><input type="radio" name="ghj" value="E" /> E</li>
	</ul>
</div>
The finished product with some simple styling

The finished product with some simple styling

Styling is split up so that positioning the child lists doesn’t interfere with the display of the un-enhanced version:

	#taxonomy { padding: 50px; background-color: #fff; height: 300px; }
	#taxonomy ul {
		margin: 0px 0px 0px 10px;
		padding: 10px;
		border: 1px solid #ccc;
		-moz-border-radius: 10px;
		-webkit-border-radius: 10px;
		border-radius: 10px;
		list-style-type: none;
		background-color: #fff;
	}
	#taxonomy ul.dyn {
		position: absolute;
		left: 50px;
		top: 50px;
		height: 280px;
		width: 180px;
	}
	#taxonomy ul ul { border-color: #fff; }
	#taxonomy ul.dyn ul
	{
		position: absolute;
		top: 0px;
		left: 200px;
		display: none;
		height: 280px;
		width: 180px;
	}
	#taxonomy ul.dyn li:hover {
		border: none;
		background-color: #eee;
		-moz-border-radius: 10px;
		-webkit-border-radius: 10px;
		border-radius: 10px;
		width: 100%;
		padding-right: 30px;
		z-index: -1;
	}
	#taxonomy ul.dyn li > ul { background-color: #eee; border-color: #eee; }
	#taxonomy ul.dyn ul li:hover, #taxonomy ul.dyn ul li > ul { border-color: #ddd; background-color: #ddd; }
	#taxonomy ul.dyn ul ul li:hover, #taxonomy ul.dyn ul ul li > ul { border-color: #ccc; background-color: #ccc; }
	#taxonomy ul.dyn ul ul ul li:hover { width: auto; padding-right: 0px; }

Finally, some Javascript breaks the list up and provides its positioning:

	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
	<script type="text/javascript">
	$(document).ready(function () {
		$("#taxonomy > ul").addClass("dyn");
		$("#taxonomy input").css("visibility","hidden");
		$("#taxonomy li").each(function (i) {
			$(this).bind("click",function(e) {
				$(this).siblings().find("ul").hide();
				$(this).children().find("ul").hide();
				$(this).children("ul:first").show();
				var rad = $(this).children("input");
				rad.attr("checked","true");
				return false;
			});
		});
	});
	</script>

Initially, I was using a noscript block to add this style: input:checked ~ ul {display:block;} and the only visual change the Javascript made was to hide the radio buttons (there was no “dyn” class). That works very well in modern browsers if your hierarchy is only two levels deep or users can only select from the lowest level, as in the classic example of vehicle make, model, and year. It didn’t work for my purposes, though, because users can select from any of four levels. It’s an easy change to make, though. The only thing to check is that IE6 is getting the correct styling, since it won’t recognize many of the selectors used here. I’m going to create a special script to handle that, but if you weren’t encumbered by that browser you could skip that step entirely.

Whew! So.. Is there a better way to accomplish this?

there's a war on??

Thursday, February 5th, 2009

The other day I offended someone on a mailing list. After advocating for the use of Word as a WYSIWYG, he’d gone on to say that he understood why others might have an issue with that, and look at this site he’d done which was “semantic” and “coded perfectly”. I went and looked and it was a mess of tables and font tags. I pointed that out – constructively, I thought – and he accused me of calling him an idiot.

I feel like things were clearer before every idiot with a wireless router had a blog (knowing I’m technically one of those idiots). When your choices for information on front-end techniques were limited to W3Schools and A List Apart, it was a lot easier to figure out what the best way to mark up a page was. Now you search for information on clearing floats and you find ten different answers. That I can live with, because in that case at least, it’s just a matter of keeping up. You know which one is the best because you’ve tried the others. Simple.

I’m bothered, though, by these people who’ve declared war on CSS. I’m bothered that there are so many of them, like the guy from the mailing list, that they’ve convinced each other there are grounds for discussion. I’m sorry, but there aren’t. Calling CSS flawed because you don’t grasp all of its idiosyncrasies is beside the point; suggesting tables as an alternative suggests that what you don’t understand, you owe to a failure to learn or to never having had the experience of trying to modify a large site laid out entirely in tables. CSS is not perfect, but it is inifitely more maintainable than tabled layouts. It means less work for developers in the long run if they’d just stop rationalizing their failure to put in the work necessary to learn to use it. To hell with semantics, to hell with download size, to hell with mobile browsers and screen readers. You use CSS instead of tables because to do otherwise is to make more work for yourself or whoever replaces you. I can’t see a reason any working front-end developer would prefer tables to CSS except as a defense against their own obsolescence.

more than an ellipsis

Wednesday, December 17th, 2008

I get a lot of hits when I Google truncating long text with an indication that more text exists, so I assume it’s a problem that interests a lot of people. There are some cool solutions for cutting off one line of text and placing an ellipsis. I was looking for code that would add a “Read More” link to the end of a block of text (meaning multiple lines), and that’s something Google wasn’t able to find for me.

Simple, unstyled test using text "See more »"

I wrote this a few months ago to provide that sort of functionality in a more flexible way. It works in FF2, FF3, Safari, Opera, IE7, and even IE6. It works in all the cases I could think of to test it, and you can put pretty much anything you want in the “Read More” link as long as you adjust the link size to fit. Which brings us to its flaws…

  • Messy! – It’s got three more tags than are semantically necessary.
  • Spacer gif – I can defend this. Or try to.
  • Cuts off halves of letters – The link doesn’t show unless the text will extend past its left border, but if half a letter extends past, half that letter is cut off by the link.
  • Math! – This solution requires adding and subtracting, but I can defend that, too.

So there are two things about this I admit may be deal-breakers. Personally, I think they’re acceptable, given that I can use this on dynamic text without having to try and translate character count into pixels with server-side code. I accept that others may feel differently. But maybe one of them will find this post and come up with a way to improve this with less code and less abrupt transitions between the long text and the links! As to the other issues..

It was actually a former coworker who came up with the idea of using an image to push the sub element that covers the link until it’s needed down to the next line. If there’s another type of element that could do this job, I would be very interested to hear about it. If inline-block ever becomes a reality, of course we could use any element we wanted. For now, however, img is the only element that provides the necessary behavior: sticks obediently to the end of the text, until so much as one pixel overflows the container at which point it snaps down to the next line. This causes the sub covering the Read More link to jump down to the next line (it’s stuck to the bottom of the text), revealing the link.

I know there are people who believe that web development should be a math-free pursuit. I don’t know why they believe that, but I’ve read their blogs and I know they’re out there. This does require calculations (meaning those things you can do with a calculator). However, short of using the limited IE-only text-overflow property, any solution will require some math. Some people might think this makes CSS flawed and too difficult; I think it’s one of its subtle beauties. Prior to PageMaker and InDesign, imagine any respectable publication laying out their newspaper or magazine without the use of a ruler. Never happened. Layouts with no math are HTML1 and we should be happy we’re now able to use the left side of our brains.

I’d love to hear about any other problems with this solution, or any suggested improvements. In the meantime, here’s the code:

<p class="trunc"><span>
<span id="dynamicText">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate
<img src="spacer_white.gif" /></span>
<sub>&nbsp;</sub>
<a href="#">See more »</a>
</span></p>
<style type="text/css">
p.trunc {
    position: relative;
    height:80px; /* line-height * desired number of lines */
    width:500px;
    overflow:hidden;
    line-height: 20px;
}
p.trunc span {
    position:relative;
    display: block;
    width:500px;
    z-index: 1;
    overflow:hidden;
}
p.trunc span#dynamicText {
	position: relative;
	display: inline;
	width: auto;
	z-index: auto;
	overflow: auto;
}
p.trunc span a {
    position:absolute;
    display: inline;
    top: 60px; /* line-height * (number of lines - 1) */
    left: 430px; /* container width - link width */
    width: 70px;  /* should be as tight as possible */
    background-color: #fff;
    z-index:2;
    text-align: center;
}
p.trunc span sub {
    position:absolute;
    bottom: 0;
	right: 0;
	width: 70px;  /* width of 'more' link */
    height: 20px; /* line-height */
    background-color: #fff;
    z-index:3;
}
p.trunc span img {
	width: 70px; /* width of 'more' link */
	height: 20px; /* line-height */
	vertical-align: top;
}
</style>
<!--[If lte IE 6]>
<style type="text/css" media="all">
p.trunc span sub {z-index:4;}
</style>
<![endif]-->

Update: There’s a cool jQuery plugin that could easily be tweaked to do the same thing. I’m not sure it will work for multiple lines, but it does trim letters neatly instead of cutting them in half, which is the big issue I have personally with the method above..

what's wrong with floats? what's wrong with CSS?

Friday, December 12th, 2008

Maybe I’m overly sensitive, but it seems like there’s been a serious shift in opinion lately away from the use of floats. (Example and example.) I had a rough time even finding out what the reasoning behind this was, but after some googling, it seems like people’s issues with the property boil down to two problems:

  1. implementations can be buggy or difficult to predict, and
  2. requires presentational markup

I have trouble swallowing either, mainly because I haven’t seen any examples. What I’m paraphrasing here is about as much detail as I could find. It’s like the joke: Why did the hipster cross the road? “You don’t know?”

So no, guilty, I don’t know. The only thing that pops into my head is adding a link or something to the right side of a heading. Generally I’d float that. Yes, if I want to keep my content in the correct order I need to wrap the text of the header itself in a span or something. That kind of sucks. Then again, I’ve heard people advocate wrapping text you want bold or italicized in a span. That is, I’m not convinced the problem is with float.

What I really lack here is a compelling alternative. Positioning things relatively or shifting elements with margins becomes no less delicate an operation than positioning with floats once a page gets beyond a certain length, and requires the same number of extraneous elements in place. Positioning everything absolutely is fine if your site has no dynamic content. I don’t actually remember the last time I worked on a site with no dynamic content. Hey, how many hipsters does it take to change a lightbulb? “You still don’t know?” I still don’t know.

Anyway, I was reading something interesting about the problems with CSS3 (via Ajaxian), and that seemed to tie into this. Among other things, the author complains that we have to add extra hooks in order to style our elements, and that properties of elements rely on the properties of their parents. Two things that make floating elements, and complex layouts in general, more painful. I was skeptical when I started reading cause, hey buddy, everyone knows that CSS is not supposed to be a programming language and making it so introduces another potential vector for attacks. But he actually talks about that (well, the former):

The CSS WG argue that CSS is meant to be simple, whilst missing the point that CSS is not meant to be anything. It’s a tool that must do a job, and the job has changed over time. CSS needs to keep up with requirements, and the best way to do that is provide adaptable tools rather than pre-packaged modules. There’s continual argument that maths, and dom traversal are too advanced for CSS, which is utter rubbish.

Good point. We obviously need a hybrid scripting/styling language – the author gives the example of designers’ reliance on jQuery – and there’s no reason that couldn’t be rolled into CSS. I may not completely grasp what he means by DOM traversal, but I’m thinking it would be really cool, in the example I gave above with the heading, to go:

h1.myHeader > *[nodeType=3] { float: left; }

I accept that his article may not have been intended to support the heretical and controversial use of floats. I’m just saying let’s not hang the entirety of CSS’s inadequacies on them.

* I am trying really hard to stay away from the suggestion that people complaining about floats aren’t giving them a chance. I’ll just say that one of the examples in the first paragraph is clearing floats by adding an extra element, instead of using the ever-popular clearfix or the substantially cleaner overflow:hidden thingy.

return of the tables?

Friday, October 24th, 2008

I have some serious issues with this article on CSS-based table layouts. Put simply, my issue is that they’re still table layouts. The author goes into how to create a table layout without an element acting as a row or a containing table, which is interesting, but doesn’t seem very useful for anything beyond three-column layouts. Circa 1998 I did not use table layouts to create nice, even columns – I used them to slice up complex designs (ok, not that complex, but they still required colspan).

I was coming around to her way of thinking until the point after the discussion of minimal markup when the author shows an example of four boxes in a grid. It falls apart for me here, because to get padding between the boxes, it seems that a faux table and two faux rows are required. I may as well use an actual table at the point, as I’ll have the same amount of superfluous markup.

I can do the same thing with just four divs. Yes, I will probably use overflow:auto to keep the height consistent. Naturally, the divs will be floated. But unlike the author of the article, I guess I don’t see any inherent problems with floating. Floating works well for me. I am a fan of it. You know what else? I think calling faux columns a trick or a hack is missing the point. Faux columns are a design solution to a design problem. There’s no trick there, they create visual separation between different areas of a page with an image that’s not part of the markup.

Maybe I just don’t get it. I came around to CSS early, with relief and no reservations. I don’t miss table layouts. They’re a bitch to maintain and they’re terrible for dynamic content or large websites. CSS has made my job incalculably easier. I can’t imagine why anyone would want to approximate those bad old days, after we’ve come so far.

navigation, borders, firefox 3

Thursday, October 9th, 2008

I’m trying to find different ways of making a typical navigation list with little pipe type dividers between the elements. I’ve seen this done frequently by adding extra list items to the menu that have special styles or (shudder) contain actual pipes. That bothers me. Waste of code, non-semantic, mixing form with function, etc., etc.

Lacking the luxury of relying on the content property, I was looking for other ways to accomplish this without adding junk to my markup. Because of the design I was trying to recreate, I had an additional problem in that the pipes between elements needed to be about 2/3 the size of the font. In the real site, this got translated to:

<style type="text/css">
#Masthead ul#Locale {
	position: absolute;
	width: 275px;
	right: 0px;
	overflow: hidden;
	margin-top: 25px;
}
#Masthead ul#Locale li {
	display: block;
	float: left;
	height: 10px;
	overflow: visible;
	border-left: 1px solid #666;
	padding: 0px 5px;
	margin: 0px;
	margin-left: -1px;
}
#Masthead ul#Locale li a { position: relative; top: -2px; font-size: 12px; }
</style>
<ul id="Locale">
	<li><a href="\" class="current">United States</a></li>
	<li><a href="\" id="indiaLink" title="Coming soon!">India</a></li>
	<li><a href="\" id="intlLink" title="Coming soon!">International</a></li>
</ul>

Not real complicated, works good, unfortunately I may need to add a tooltip overlaying the links and overflow:hidden is not mixing real well with that concept. That’s why I started looking for other ideas.. I came up with six methods that looked pretty and were accomplished with minimal typing. Here they are in Firefox 3:

All six menus, FF3

All six menus, FF3

However, most of those don’t work in other browsers. Safari is closest, FF2 is reasonable but ugly, Opera laughed so hard at my attempts to coerce its cooperation that milk came out of its nose. I’ve run into this a few times, and I’m not really sure what’s going on. I’m used to FF showing an accurate representation, and I’m having a hard time tracking down firm info on exactly where the newest version is broken.

This is what I have right now. I guess I’m going to start over from scratch and test on Opera, Safari, and FF2 before checking the browsers on my PC.

UPDATE: Oh yeah. Line-height. Right. Below appears to work in everything but IE.

ul, li, a { position: relative; }
ul.nav, ul.nav2 { list-style-type: none; background-color: #8c432a; overflow: auto; height: auto; min-height: 24px; padding: 0px; line-height: 24px; }
ul.nav li { float: left; width: 5em; text-align: center; vertical-align: middle; }
ul.nav li *, ul.nav2 * { vertical-align: middle; padding: 5px 0px; }
ul.nav2 li { display: inline; padding: 0px 20px; height: auto; }
a, a:link, a:visited { color: #cfc; text-decoration: none; font-weight: bold; width: auto; }
a:hover, a:active { color: #cff; }

ul.bg li { background-color: #c93; height: 24px; margin-left: 2px; }

ul.over li { line-height: 10px; border-left: 1px solid #cff; margin: 7px 0px 7px -1px; }
ul.over li a { vertical-align: middle;  }

ul.img li { background: transparent url(border.gif) left 1px no-repeat; margin-left: -1px; }
ul.img li a { padding: 5px 0px; }

ul.nav2.bg { font-size: .1px; }
ul.nav2.bg li { margin: 0px 0px 0px 2px; padding: 8px 20px; font-size: 15.5px; }

ul.nav2.over li { line-height: 24px; font-size: 2px; padding: 4px 20px; }
ul.nav2.over li a { font-size: 15.5px; }

ul.nav2.img li { background: transparent url(border.gif) left top no-repeat; padding: 2px 20px; }

(Classes of the ULs are “nav” for the floats, “nav2″ for the inlines. Within those sets, they go in the same order as the CSS – “bg”, “over”, “img”.)

UPDATE again: Here’s the conditional styling for IE. It doesn’t make all the menus look the same as they look in other browsers, but it makes them usable and gets them reasonably close, visually.

<!--[if lte IE 7]>
<style type="text/css" media="screen">
ul.nav, ul.nav2 { height: 24px; overflow: hidden; }
ul.nav2 li { top: 2px; }
ul.over { padding: 0px 0px; overflow: hidden; }
ul.over li { margin: 0px; left: -1px; }
ul.img li { background: transparent url(border.gif) 0px 1px no-repeat !important; zoom: 1; padding: 5px 20px; }
</style>
<![endif]-->
<!--[if IE 7]>
<style type="text/css" media="screen">
ul.over { padding: 0px; overflow: hidden; }
ul.over li { margin: 0px; left: -1px; top: 9px; line-height: 12px !important; overflow: visible; }
ul.over li a { top: -4px; }
</style>
<![endif]-->

blah blah blah CSS variables

Wednesday, October 8th, 2008

Admittedly, it’s possible I’m missing something, but the talk about CSS variables/constants online sort of confuses me. I can see the utility they’d offer, but I kind of side with Bert Bos on a lot of his points about the trade-offs involved.

I’ve totally been there, trying to find the salmon color used in the header links on version 0.42 of a site that’s grown to encompass ten different stylesheets, unable to accurately pick the color from the image in the third-hand PDF, wishing it just had a simple name defined in the base stylesheet. However, at some point trying to remember the variable name is going to be only slightly easier than remembering the hex color. Moreover, you save no code. You’re just substituting one string for another, you’re redefining whatever you’re going to redefine, the fundamental processes we struggle with now become no simpler.

I’d like to see some sort of CSS micro-style instead of variables. I think this would answer a few of the points I’ve heard raised against variables, and would also save code and be more useful. I’m talking about extending the concept of inheritance so that we can invoke it programmatically instead of having to rely on an element’s position within the document. (Maybe something like this already exists. Maybe I’m an idiot. This is always possible, especially since this seems to me like the obvious thing to do.)

What I’m talking about is something like so:

// here's the variable
$specialNote { font-size: 12px; color: #333; padding: 5px; background-color: #eee; border: 1px solid #ccc; }
// here's its basic implementation
($specialNote) #mainContent p.specialNote { font-size: inherit; }
// here it's used somewhere completely unrelated, and we add only what differs
($specialNote) #rightSide dl.specialList dd span.specialNote { display: inline-block; }

I think that would be really cool.

forms without lists

Wednesday, October 8th, 2008

This is the most recent product in a continuing attempt at making a flexible form that doesn’t require lists:

<fieldset id="floatlabel">
	<legend>Floated Labels</legend>
	<div onmouseover="this.className='hilite';" onmouseout="this.className='';">
		<label>Lorem ipsum</label>
			<div class="optionGroup">
				<label for="Radio1">
				<input type="radio" name="radMenut" id="Radio1" value="1" /> Omnivorous</label>
				<label for="Radio2">
				<input type="radio" name="radMenut" id="Radio2" value="2" /> Vegetarian</label>
				<label for="Radio3">
				<input type="radio" name="radMenut" id="Radio3" value="3" /> Vegan</label>
			</div><hr /><!-- if div not needed for styling, etc., h-rule can be used here to create structure without css, fix for ie6 -->
	</div>
	<div onmouseover="this.className='hilite';" onmouseout="this.className='';">
		<label for="txtMiddle0">dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Why the absurdly long label? Good to test in case of dynamic or translated text.</label>
			<p><b>Note:</b> Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius.</p>
			<input type="text" id="txtMiddle0" />
			<i>ex: Typi non habent claritatem insitam;</i><hr /></div>
	<div onmouseover="this.className='hilite';" onmouseout="this.className='';">
		<label>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, </label>
			<div class="optionStack">
				<label for="Checkbox1">
				<input type="checkbox" name="chkSeatingt" id="Checkbox1" value="1" /> Stage</label>
				<label for="Checkbox2">
				<input type="checkbox" name="chkSeatingt" id="Checkbox2" value="2" /> Dancefloor</label>
				<label for="Checkbox3">
				<input type="checkbox" name="chkSeatingt" id="Checkbox3" value="3" /> Balcony</label>
			</div><hr /></div>
	<div onmouseover="this.className='hilite';" onmouseout="this.className='';">
		<label for="txtFirst">First Name</label>
			<input type="text" id="Text1" /><hr /></div>
	<div onmouseover="this.className='hilite';" onmouseout="this.className='';">
		<label for="txtMiddle">Middle Name</label>
			<input type="text" id="Text2" /><hr /></div>
	<div onmouseover="this.className='hilite';" onmouseout="this.className='';">
		<label for="txtLast">Last Name</label>
			<input type="text" id="Text3" /><hr /></div>
	<div onmouseover="this.className='hilite';" onmouseout="this.className='';">
		<label for="selSuffix0">vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</label>
			<select id="Select1"><option>(none)</option><option>Sr.</option><option>Jr.</option></select>
			<i>ex: Typi non habent claritatem insitam;</i><hr /></div>
	<div onmouseover="this.className='hilite';" onmouseout="this.className='';">
		<label for="btnSubmit" class="buttonLabel">Submit this:</label>
			<input type="button" id="btnSubmit" value="Go Ahead" />
			<input type="button" id="btnCancel" value="Nevermind" /><hr /></div>
</fieldset>

It’s heavier than it needs to be because it has both a div wrapping each item and a horizontal rule after. One or the other does the trick. I’m pleased that it manages, even with both tags, to have fewer tags than you’d need for a form with the same elements nestled in a list, which seems to be the cool thing to do these days (myself, I’m in the not every collection is a list camp). I’m curious what a list would offer it that it doesn’t have now. I think this looks better with the CSS stripped out than it would if everything had excess bullets next to it, as well.

The CSS is like so:

.example, .note, i, p { color: #999; font-style: italic; line-height: 1em; }
.example, i { white-space: nowrap; }
.note, p { background-color: #f6f6f6; padding: 10px; }
input, select { line-height: 1em; font-size: inherit; margin-bottom: .8em; position: relative; }
hr { display: none; }
.hilite { clear: both; position: relative; overflow: hidden; height: 100%; }
.buttonLabel { visibility: hidden; }
.optionStack *, .optionStack label *, .optionGroup label *, .optionGroup * , .optionLabel * { vertical-align: middle; }
#floatlabel { position: relative; border: 1px solid #999; padding: 10px; margin: 10px 0px; font-family: Garamond; font-size: 1.1em; }
#floatlabel div { margin: 5px 0px 0px; padding: 0px; clear: both; position: relative; overflow: hidden; height: 100%; }
#floatlabel .hilite { background-color: #f3f3ee; border: none; padding: 0px; margin: 5px 0px 0px; }
#floatlabel label { margin-bottom: .8em; border-bottom: solid #999 1px; position: relative; float: left; width: 300px; clear: both; display: block; line-height: 1.5em !important; margin-right: 10px; }
#floatlabel input, #floatlabel select, #floatlabel .optionGroup, #floatlabel .optionStack {
	float: left; display: block; position: relative; top: 0px; margin-bottom: .8em; margin-right: 10px; font-family: Garamond; font-size: 1em; }
#floatlabel input, #floatlabel select { border: double #999 3px; }
#floatlabel .hilite input, #floatlabel .hilite select { border: double #cc8 3px; }
#floatlabel i, #floatlabel p { position: relative; float: left; }
#floatlabel i { width: 200px; white-space: normal; left: 0px; }
#floatlabel p { background: transparent url(/newsletters/img/flourish.jpg) center 95% no-repeat; padding-bottom: 20px; width: 200px; float: right; display: inline; margin: 0px; border: double #999 3px; }
#floatlabel .optionGroup, #floatlabel .optionStack { overflow: hidden; margin: 0px 0px .8em; clear: none; }
#floatlabel .optionGroup label, #floatlabel .optionStack label { border: none; width: auto; margin-bottom: 0px !important; vertical-align: center; }
#floatlabel .optionGroup, #floatlabel .optionGroup label { clear: none; }

I’m still working on it – the CSS could be cleaned up – but it’s nice to know that it can be done. The important things, to me, are that it allows for infinitely expanding labels, as well as notes and examples.

Screenshot of the finished product

Screenshot of the finished product