Search code examples
textalignment

How to align text after colon


I would like to align a few lines of text after the colon in each line, so it currently looks like:

Your Membership Number is: 123456789
Your temporary PIN for website access is: 1234

I would like it to look like:

Your Membership Number is:                         123456789
Your temporary PIN for website access is:     1234

Is it possible to do this without using a table?

Kind regards


Solution

  • You can do it with HTML like this:

    <div>
        <span class="col1">Your Membership Number is:</span>
        <span>123456789</span>
    </div>
    <div>
        <span class="col1">Your temporary PIN for website access is:</span>
        <span>1234</span>
    </div>  
    

    and css like this:

    .col1 {
    width: 300px;
    float: left;
    }