Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8930263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:51:11+00:00 2026-06-15T08:51:11+00:00

I want to horizontally center a span inside an a-tag. The problem is that

  • 0

I want to horizontally center a span inside an a-tag. The problem is that I can’t set the height nor the width of the span. My markups is as follows:

<div class="footer">
     <a href="#">
          <span>Show/Hide</span>
     </a>
</div>

And the css:

.footer {position:absolute; bottom:0; width:100%;}
.footer a {display:block; background:orange; text-align:center;}
.footer a span {background:#FFF; font-size:12px; width:100px;}

I’ve tried everything, but think I need some sort of float somewhere, but don’t know. Help are gladly appreciated! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:51:13+00:00Added an answer on June 15, 2026 at 8:51 am

    You can’t set dimensions of display: inline elements.

    You can either have both the a and the span have display: block, if you want to explicitly set its width:

    .footer {position:absolute; bottom:0; width:100%;}
    .footer a {display:block; background:orange;} /* no need to center text, here */
    .footer a span {
      display: block; /* give it a box layout */
      margin: 0px auto; /* center it horizontally */
      width:100px; /* give it explicit absolute size */
      text-align: center; /* you might center the content here, though */
      background:#FFF; font-size:12px;}
    

    or just use text-align: center as you are already doing:

    .footer {position:absolute; bottom:0; width:100%;}
    .footer a {display:block; background:orange; text-align:center;}
    .footer a span {background:#FFF; font-size:12px;
      padding: 0px 30px;} /* if you only want some padding, and not a fixed width
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 divs that positioned horizontally ( float:left; width:50%; ). But i want
I want to center divs, something like: <div style='width:100%;'> <div style='float:left; width=40px; height=40px;'></div> <div
I have a div with width:100px and height:100px (say) Inside that, there is just
What I want is sticky footer with 100% width (or footer that stretches horizontally
I have a div that I want to center horizontally and vertically. For the
I want to horizontally center two (or possibly more) inline-block elements inside a container
I have an input element that width is 20% and I want to center
I have a horizontal unordered list I want to center horizontally in a div
I want to make a div that is centered (horizontally and vertically). It should
I have a div and I want to align in the center of that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.