For explanation imagine a simple address. Written in a HTML paragraph with line breaks it would like this:
Street: Example Street 1
City: Vienna
Zip Code: 1010
Country: Austria
Most of the time that's completely okay, but sometimes I have to achieve the following output:
Street: Example Street 1
City: Vienna
Zip Code: 1010
Country: Austria
My thoughts so far:
How do you achieve this output (using HTML and/or CSS)?
I think you've taken "tables are bad" concept to the extreme.
What you've got fits very nicely into concept of rows and columns, with headers (<th>
) and data (<td>
) – based on semantics, not only layout.
If you want to make it more explicit that it's an address, then use adr Microformat or add a <caption>
.
Wrong approaches:
<dl>
: "1010" is not a definition of "Zip Code". The other way round it makes a bit more sense, but the relationship is just as clear with <th>
→ <td>
, it doesn't rely on CSS, and will look perfect regearless of user's font size.<th>
will be perfectly rendered even in lynx! Address in <dl>
without CSS trick will look weird.<address>
element may not be appropriate for this, because it is intended only for page author's/maintainer's contact information. It also allows inline content only, so you would lose structure of the address.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With