How can I have centered text and right-aligned image in the same element?

Posted by Ethan on Stack Overflow See other posts from Stack Overflow or by Ethan
Published on 2011-01-08T02:07:11Z Indexed on 2011/01/08 2:54 UTC
Read the original article Hit count: 192

Filed under:
|
|

I have some th elements with text in them that should be centered and they also contain images:

alt text

The up/down arrow graphic is a separate image.

My question is, what is the simplest reliable way to position that image over to the right side of the th element while keeping the text centered?

I'm open to using jQuery/JavaScript if there's a reasonably simple way to do it.

One caveat: I need the up/down graphic to be a separate image, not part of the header background.

        <th> 
          Title
          <img src='/images/sort_unsorted.jpg' /> 
        </th>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html