Search code examples
csshtmlpositioning

Setting text at right side of screen


Below is how my screen look like

*********************************************************
*                      Welcome to Mysite                *
*          ______________________________________       *
*                    Welcome user, logout.              *
*               Mon, 02-Jul-2012 22:59:07 AST           *
*          ______________________________________       *
*                                                       *
*                                                       *
*                                                       *
*                                                       *

Code I have is

<html>
    <body>
        <center>
            Welcome to Mysite<br />
            <hr width="40%" /><br />
            Welcome user, logout</br>
            Mon, 02-Jul-2012 22:59:07 AST<br />
            <hr width="40%" /><br />
    </center>
    </body>
</html>

What I want is something like below.

*********************************************************
*                      Welcome to Mysite                *
*          ______________________________________       *
*                           Welcome user, logout.       *
*                   Mon, 02-Jul-2012 22:59:07 AST       *
*          ______________________________________       *
*                                                       *
*                                                       *
*                                                       *
*                                                       *

That means set everything to right. I believe this can be done using CSS, but I don't know how to set the position.

Note : Text should not be at the right side of screen. It should be till the right side of the horizontal line.

Any idea how to get this done?


Update 1

I don't want output like below.

*********************************************************
*                      Welcome to Mysite                *
*          ______________________________________       *
*                                  Welcome user, logout.*
*                          Mon, 02-Jul-2012 22:59:07 AST*
*          ______________________________________       *
*                                                       *
*                                                       *
*                                                       *
*                                                       *

Solution

  • Here you go: jsFiddle

    You just needed to place the content in a <div> and add the following CSS to it.

    .container {
        width:40%;
        text-align:right;
    }