Simulating HTML5's placeholder attribute with jQuery
I recently discussed the placeholder attribute in HTML5. Today, I needed exactly such a behavior for a site I'm working on, so I knocked together a reusable, unobtrusive solution with jQuery.
Forms in HTML5
The HTML5 spec continues to grind inexorably toward publication. I've just spent a while with the latest draft, and at least with respect to forms, I like what I see. Here's a roundup.
Toward Better Buttons
I see this a lot:
<input type="submit" class="button" value="Save Changes" />Because the <input /> element can represent many things other than a button—and because many browsers still don't support attribute selectors, such as input[type=button]—the author has added class="button" for the sole purpose of giving the stylesheet something to match on.
May I suggest a better way?
target="_blank" for XHTML Strict
For better or for worse, it's a widespread convention for offsite links to open in a new window. This is usually achieved by setting the attribute target="_blank" on the link in question.
Of course, the target attribute is illegal in XHTML Strict—so this bit of functionality of will invalidate your pages.
I whipped up a simple fix to this problem. Here's the demo and download page.
Three essential Firefox extensions for web developers
Firefox is beloved by web developers for its compliance with W3C standards, its open-source nature, and its general awesomeness. But its vast library of genuinely useful extensions and Greasemonkey scripts is surely a big part of the attraction, too. Here are three that I couldn't live without.
Styling horizontal rules in Internet Explorer 6 & 7
Scott Klarr has a nice post about the difficulties of styling horizontal rules with CSS—owing mainly, of course, to problems in Internet Explorer.
In short, IE 6 and 7 insist on putting a border around horizontal rules, no matter how you set up your stylesheet.
Scott offers a simple but elegant solution which relies on jQuery. That's fine if you're already using jQuery in your project, but if you're not, it's hard to justify the extra payload to fix a simple cosmetic issue.
I've written a standalone version of Scott's script. At less than 350 bytes, it's a very lightweight solution, and it's easy to implement. Here's a demo page. As Scott's post explains, it simply replaces all <hr /> elements with <div class="iehrfix"></div> in the affected versions of IE.
PECL DLLs
After searching high and low for a DLL version of the PDFLib PECL extension (pecl4win.php.net is down, and apparently has been for a while), I stumbled across this blog post, which offers ZIP files of both thread-safe and non-thread-safe versions of all PECL DLLs.
A comprehensive JavaScript pad function
I wanted a JavaScript function for padding strings, but I couldn't find one that met my criteria. So, I wrote my own.
- Minified (850 bytes)
- Uncompressed
It behaves identically to PHP's str_pad() function, and has been unit tested in Firefox 3, Safari 3, Chrome, IE6, and IE7.
Read the rest of this entry »
JavaScript Standard Library 1.8+
I just came across Andrea Giammarchi's JavaScript Standard Library, a ≈2.7KB library which transparently adds JavaScript 1.6 methods (mostly the new Array stuff) to browsers which don't support them natively.
Surprisingly, this is the first library I've seen whose sole purpose is JavaScript version compatibility. Andrea says it provides "a quite totally standard environment", and offers some unit tests.
Read the rest of this entry »
Welcome!
Welcome to my new site. Things are still a little rough, but I'll be settling in over the next few days.
On this blog, I'll be writing about all aspects of the web, both technical and cultural. The technical stuff will have an emphasis on open-source technologies and the LAMP stack. The cultural stuff will be more free-form.
This is my first WordPress theme; please let me know if you spot anything out of order. I think it turned out fairly well.
Please feel free to comment and subscribe to my RSS feed—I'd love to hear your reactions!
