Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Aligning Text

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #159259
    djpic
    Participant

    I want to align text in a group of like so:

    Subtotal:      $500
    Total:         $500
    

    Here is the HTML I currently have:

    <p>Subtotal:<span>$500</span></p>

    <p>Total:<span>$500</span></p>

    Is this even possible or should I look for an alternate way to lay it out?

    Thanks.

    #159261
    djpic
    Participant

    Here is what I ended up doing:

    <style>
    p {
      width: 300px'
      display: block;
      clear: both;
    }
    span {
      display: inline-block;
    }
    .label {
      font-weight: bold;
      width: 65%;
    }
    .value {
      width: 35%;
    }
    </style>
    <p><span class="label">Subtotal:</span><span class="value">$500</span></p>
    
    #159262
    Senff
    Participant

    This is why the table element exists.

    #159290
    Mavericks
    Participant

    Yep @Senff .

    A lot of people shy away from using the table at all but in a case like this one… you are spending more time and resources to format it without using tables than not.

    In the code you have above, you basically created a table.

    Compare: http://cdpn.io/cnBvj

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.