Problem

In a table with one column showing an event start and end time, I wanted the end time to also appear after a carriage return, resembling the following:

My Example
8:00 AM - 9:00 AM My Event

It's a shame to use < br /> tags, since that's more of a presentational element than content. The problem here then how do we get the span element "9:00 AM" to know it has to be on the following line? We cannot use clear:both because it was never floated and spans cannot float.

Solution:

HTML:
  1.    <caption>My Example</caption>
  2.    <tr>
  3.       <td>8:00 AM - <span class="end-time">9:00 AM</span></td>
  4.       <td>My Event</td>
  5.    </tr>
  6. </table>

CSS:
  1. .end-time{
  2.      display: block;
  3. }

Using display:block will make the span behave as a div, and will require it's own block, thus forcing the visual effect of a carriage return. Cake.

Popularity: 13% [?]

Share and Enjoy:
  • del.icio.us
  • Digg
  • Reddit
  • TwitThis
  • Google Bookmarks
  • StumbleUpon
  • Facebook
  • E-mail this story to a friend!
  • Print this article!