The
Palm
Civet

Posts tagged typography

avoiding typographic widows with jquery

here is a quick jquery clip for avoiding typographic widows, or in more words, ensuring good typesetting practice by preventing the last word in an element from ending up on a line by itself. this is most useful for things like headlines and article titles.

just insert the elements you want to unwidowize (is that even a word?) into the array that the regular expression replacement function will run through.


$(document).ready(function(){
	$('a.link, h2 a').each(function(){
		$(this).html($(this).text().replace(/ (\w+)$/,' $1'));
	});
});

{via}

compiling and sharing code, ideas, and tools for making better websites and applications.

by justin talbott {email me}

what is a palm civet?