Here's a solution using JavaScript:
Script example
Here is the code that runs it:
Javascript
var spans = document.querySelectorAll('.rw-words span'), maxwidth = 0, words = document.querySelector('.rw-words'); for (var i=0,l=spans.length;i<l;i++){ console.log(i + ' width: ' + spans[i].offsetWidth) maxwidth = spans[i].offsetWidth > maxwidth ? spans[i].offsetWidth : maxwidth; } words.style.width = maxwidth + 'px'
CSS
.rw-words{ display: inline-block; vertical-align: top; text-indent: 2px; }
EDIT
Here is much cleaner JavaScript that achieves the same:
var spans = [].slice.call(document.querySelectorAll('.rw-words span')), words = document.querySelector('.rw-words'), maxwidth = Math.max.apply(null, spans.map(function (item) { return item.offsetWidth; })); words.style.width = maxwidth + 'px'
source share