CSS Inline Element Line Break
CSS March 9th, 2007Problem
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:
| 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:
CSS:
-
.end-time{
-
display: block;
-
}
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% [?]









Recent Comments