How to stop browsers wrapping the date time table column

Tables (real tables I mean, not pseudo ones for display purposes) are wonderful things most of the time. The browsers automatically adjust the column sizes for you based on the content.  Isn’t that great!

Except when they make ‘bad decisions’ such as

  • wrap when you do not want them to (the break-word or word wrap question – a space means a new word doesn’t it?… no not always)
  • or don’t wrap when you want to (aka the “long url” problem)
Unwanted wrapped times

Date or time format with a space

Browsers will think that it is quite ok to break your date and time column at the space.   Since you do not know the text zoom or browser a person may be using, I suggest thinking carefully about where those spaces should be, or if they should be there at all.

Please don’t wrap….

Css Options – Allow enough column width maybe?

Not a great option for non techies. Also what’s enough? Will you end up with a overly wide column 99 % of the time to cater for the 1% time that there is a wide value?

Remove the spaces, use commas or non breaking spaces

To fix a date / time wrapping problem in the calendar or events list, one simple answer is not to have spaces.  Use a comma maybe if it makes sense.

Alternate date and time formatting

Avoiding the spaces is my recommended option.

In ical-events-list settings

Date and Time Format Settings in Ical Events List

For formatting codes, see php date:

Not So Good
(word/line may break at space)
Better
(not ideal, just better)
Result
g:i a g:ia 12:16pm
D j S D,jS Thu,9th
F Y F,Y September, 2010
F j, Y g:i a F j,Y g:ia September 9,2010 1:49pm

It would be nice if one could enter in the plugins time format:

g:i\&\n\b\s\p\;a,

but for the moment that does not work (a plain space is returned to the display html, not a non breaking space).   Date time formatting combined with localisation requirements is very complex, and there are more important features to work on.

Entering a non breaking space in the time format option

There are a number of other solutions presented on the web, however I think that they are not worth entertaining (either non-standard, not enough browser support, or do not validate).

Resources:

  • jkorpela has a detailed article on what he calls “word division”.  He discusses how to avoid line breaks and how to suggest ‘word’ breaks.
  • Quirks mode (always a useful cross reference) lists the browser compatibility for the little known < wbr > word break tag. (IE 8 a problem, and causes validation errors )