SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Align Anchor?

Hybrid View

  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    2,887
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Align Anchor?

    Is it possible to align an Anchor element?

    This is not working...
    Code:
    <div id="container">
    	<a href="#">
    		<strong>DoubleDee</strong>
    	</a>

    Code:
    #boxMemberProfile #container{
    	display: block;
    	width: 50%;
    	margin: 0 auto;
    	background: #ffc;
    }
    
    #container a{
    	text-align: right;
    }

    Debbie

  2. #2
    The CSS Clinic is open silver trophybronze trophy
    SitePoint Award Recipient Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    37,773
    Mentioned
    99 Post(s)
    Tagged
    3 Thread(s)
    Hi Debbie,

    Anchors are inline elements and are therefore always aligned right They are also always aligned left and center as well

    An inline element is only as wide as the content it contains so text-alignment doesn't apply because there is no where to move it to.

    If you set the anchor to display:block then it will fill the available horizontal space and then the text-alignment will work. Or alternatively apply the text-alignment to the block parent instead (#container)

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
  •