Hoopla!

now with extra whiz-bang!

Hoopla!

Using Definition Lists (dl tag) for forms

August 03, 2006 · 0 comments

I’ve been mostly table-free for a while now in my layouts but I’ve had a particular bit of trouble with forms. Getting the labels and inputs aligned has been a huge pain because it seems like every form has a tons of exceptions to it and doing anything to the `input` tag means you need to go through and exclude all your radio buttons from it. I don’t know about you but most of my clients look quizzically at radio buttons that are 150px wide.

Enter Definition Lists

 Garbage Burrito has an awesome post about the html tags we’ve all forgotten about – definition lists among them. Thabenksta reintroduced me to this wonderful tag and it’s saved my ass just today.

The thing about definition lists is that they contain sets of pairs. The problem with `ul`s and `divs` has been the the only way to put an `input` into it and making that `input` behave differently than a `label` is to give s special class to the `input` or to the `label`.

Here’s some code that I’ve had to use to make a `ul`-based form with aligned inputs and labels (labels on the left):

<style>
input.radio {
  width: auto;
}
label {
  cursor: pointer;
}
form.aligned label, form.aligned .label {
  margin: 2px 0px;
  border-top: 1px solid #EEE;
  display: block;
  clear: left;
  float: left;
  width: 90px;
  font-size: 1em;
  font-weight: bold;
}
form.aligned input, form.aligned .input, form.aligned textarea {
  margin: 2px 0px;
  display: block;
  clear: none;
  float: left;
}

</style>

That’s a mouthful. And, even worse, its just not pretty.

Here’s an example of an aligned form using a `dl` tag. I put labels in the `dt` and inputs (or whatever, it’s encapsulated!) in the `dd`.

<style>
dt {
  min-height: 1em; /* to make sure it stays aligned if it's empty */
  float: left;
  clear: left;
}
dd {
  min-height: 1em;
  margin-left: 100px;
}

</style>
That’s it. Then it’s not only pretty but also much more semantic to code up my forms:

Onward and upward.

→ 0 comments Tags:

Zipcodes by City and State - Complete Listing

May 28, 2006 · 2 comments

It took me forever to find this list. I figured I’d post it prominently just so nobody else had to go through the same trouble.

This is a CSV file of zip codes, main city within the zip code (by the USPS’s reckoning) and the two-letter state abbreviation.

Download directly: download zipcode list as csv file

Or view this full post to see a short sample from the complete list.
ZIP,City,ST
00501,Holtsville,NY
00544,Holtsville,NY
00601,Adjuntas,PR
00602,Aguada,PR
00603,Aguadilla,PR
00604,Aguadilla,PR
00605,Aguadilla,PR
00606,Maricao,PR
00610,Anasco,PR
00611,Angeles,PR
00612,Arecibo,PR
00613,Arecibo,PR
00614,Arecibo,PR
00616,Bajadero,PR
00617,Barceloneta,PR
00622,Boqueron,PR
00623,Cabo Rojo,PR
00624,Penuelas,PR
00627,Camuy,PR
00631,Castaner,PR
..................
48730,East Tawas,MI
48731,Elkton,MI
48732,Essexville,MI
48733,Fairgrove,MI
48734,Frankenmuth,MI
48735,Gagetown,MI
48736,Gilford,MI
48737,Glennie,MI
48738,Greenbush,MI
48739,Hale,MI
48740,Harrisville,MI
48741,Kingston,MI
48742,Lincoln,MI
48743,Long Lake,MI
48744,Mayville,MI
48745,Mikado,MI
48746,Millington,MI
48747,Munger,MI
48748,National City,MI
48749,Omer,MI
48750,Oscoda,MI
48754,Owendale,MI
48755,Pigeon,MI
48756,Prescott,MI
48757,Reese,MI
48758,Richville,MI
48759,Sebewaing,MI
48760,Silverwood,MI
48761,South Branch,MI
48762,Spruce,MI
48763,Tawas City,MI
48764,Tawas City,MI
48765,Turner,MI
48766,Twining,MI
48767,Unionville,MI
48768,Vassar,MI
48769,Tuscola,MI

→ 2 comments Tags: