SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Dec 2009
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to do right text align ?

    Hi, I want to give a text-align: right to the red marked element. I want the text to be right aligned. ............but this does not work. How do I right align text inside a span ?

    Here is the part of relevant HTML

    <div>
    <span><label for="localadult">Online Payment Tax/label></span>
    <span>-</span>
    <span><label for="Rs" style="width: 50px;">(Rs)</label></span>
    <span>10,000</span>
    </div>

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,598
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    Spans are inline elements, so they don't respond to settings like that (which are for block level elements). The solution is to set the span to display: block, like so:

    Code:
    span {
        display: block;
        text-align: right;
    }
    If you only want the one span set to display: block, then give it a special class:

    Code:
    <span class="special">10,000</span>
    
    .special {
        display: block; 
        text-align: right;
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •