On, for example, GitHub, if you select code it only selects the code not the line numbers next to it:

This is because they use a table – the line numbers in a td and the code in a td.
How can I achieve this with a div?
EDIT: Please see http://www.duncannz.com and try to highlight text. I want the selection thing to only be inside the content area, not to fill the width of the page (eg selection background doesn’t go past the black border)
Example: http://jsfiddle.net/gfp28/
CSS:
If you add this to your css, it should restrict the highlighting to the width of the container: