SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    May 2010
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I centre text and increase height of an a href tag at the same time ?

    I want to increase the height of a A href tag in xhtml strict, but also need to align the text centre by using a line-height which only works with inline elements, but need the height attribute to work which means it needs to be block level. Any suggestions ?

  2. #2
    Ripe Tomatos silver trophybronze trophy Rayzur's Avatar
    Join Date
    Jun 2007
    Location
    Texas
    Posts
    4,174
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    I'm not sure where the anchor is at on your page, whether it is wrapped in an LI or in a string of text. Depending on where it is at will determine what you do to set a height.

    As you have stated the anchor needs to be a block in order to take on dimensions. That can be obviously be done by setting it as display:block. But it can also be floated or set as display:inline-block to generate a block box around it.

    If it is in a horizontal menu then you could float it. If it is an anchor within a string of text then inline-block would work. If it is a vertical menu then display:block will work.

    And you can set a line-height on any of those block boxes that is the same as their height to center the text vertically.

  3. #3
    SitePoint Zealot
    Join Date
    May 2010
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that, I really shouldnt keep posting these up in lazyness, I just started again from scratch and it worked first time, using display block , dunno what happen before.

    Thanks again , much apreciated.


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
  •