tags:

views:

179

answers:

3

It's kinda difficult to explain what I want to achieve (and feel free to modify the title if you can think of a better one), so I'll give you an example:

 Street: First Lane
         South side 28
   City: Duckburg
Country: Disneyland
    ZIP: 1234567890-XY

This is what I want the user to see. But I also want the user to be able to select only the right column, so he can copy-paste the contents of it elsewhere. If I do this with a table, the user can only select whole rows, and a copy-paste operation will copy row headers as well. If I do this with two separate containers next to each other, the labels get out of synch with the contents if some item has more than one line.

Can this be achieved somehow?

+1  A: 

Yes. Try something like this:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Page Title</title>
    <style type="text/css" media="screen">
     #left_side { float: left; text-align: right;}
    </style>
</head>
<body>
    <div id="container">
     <div id="left_side">
      Street:<br><br>
      City:<br>
      Country:<br>
      ZIP:
     </div>
     <div id="right_side">
      First Lane<br>
      South side 28<br>
      Duckburg<br>
      Disneyland<br>
      1234567890-XY
     </div>
    </div>  
</body>
</html>
Krule
This becomes nonsense without visual CSS being applied. Anything that handles the data in a linear fashion (such as a search engine or screen reader) will get the labels one after the other before any of the address arrives.
David Dorward
Neither is important in my case - this is for a HTML formatted email. If google gets to indexing this, that will mean a serious security hole somewhere. :D However, this way requires me to check each item to see how many lines it has. Possible of course, but I'd rather prefer something more elegant.
Vilx-
Emails are more likely to be read in a linear fashion — people still use screen readers with email, people view email in plain text mode, email clients often have poor support for CSS, etc, etc.
David Dorward
I'll be supplying a plain-text alternative manually.
Vilx-
Well, you never sad why do you need it :)Since email readers do have poor support for CSS, I would suggest you go with your initial, table based, solution.
Krule
Well, true, I didn't say it. And it seems to me that the broader question is more interesting too. So I won't modify it, although I might end up with lots of unusable answers in this way. :P
Vilx-
A: 

Could you have all of the right hand column of your example in 1 cell somehow? That way it would be all selected together.

The row headers would stay aligned as long as the number of rows in each part of the address was always the same.

cheesysam
Do you mean the same as Krule's answer? If so, check my comment to it.
Vilx-
+1  A: 
Arthur Ronald F D Garcia
OMFG! And all this for a tiny HTML-formatted email which otherwise will have only one more line of text in it! O_O I'll pass, thank you!
Vilx-
You can extend Yahoo datatable in order to set up specific feature. It is a powerfull component that solves any question when the subject is HTML table. I use it successfully.
Arthur Ronald F D Garcia
It does seem powerful indeed, and I'm sure that many people will find this answer useful. :)
Vilx-